# About enrolled cows
table1(~as.factor(presence_cm_previous_cow) + as.factor(Lact.SCM) + Lact.group + season.enrollment,data=Doff.by.cow.3 )
| Overall (N=488) |
|
|---|---|
| as.factor(presence_cm_previous_cow) | |
| 0 | 328 (67.2%) |
| 1 | 160 (32.8%) |
| as.factor(Lact.SCM) | |
| 0 | 284 (58.2%) |
| 1 | 204 (41.8%) |
| Lact.group | |
| 1 | 155 (31.8%) |
| 2 | 187 (38.3%) |
| 3 | 146 (29.9%) |
| season.enrollment | |
| W | 197 (40.4%) |
| SP | 0 (0%) |
| SU | 49 (10.0%) |
| A | 242 (49.6%) |
# ----- Dry-off -----
# Prevalence IMI quarter
table(Doff.by.quarter.2$Contaminated)
##
## 0 1
## 1784 121
prop.table(table(Doff.by.quarter.2$Contaminated))
##
## 0 1
## 0.93648294 0.06351706
table(Doff.by.quarter.2$IMI)
##
## 0 1
## 1034 750
prop.table(table(Doff.by.quarter.2$IMI))
##
## 0 1
## 0.5795964 0.4204036
table(Doff.by.quarter.2$Staph.aureus)
##
## 0 1
## 1781 3
prop.table(table(Doff.by.quarter.2$Staph.aureus))
##
## 0 1
## 0.998318386 0.001681614
table(Doff.by.quarter.2$CNS)
##
## 0 1
## 1327 457
prop.table(table(Doff.by.quarter.2$CNS))
##
## 0 1
## 0.7438341 0.2561659
table(Doff.by.quarter.2$SSLO)
##
## 0 1
## 1322 462
prop.table(table(Doff.by.quarter.2$SSLO))
##
## 0 1
## 0.7410314 0.2589686
table(Doff.by.quarter.2$gram.negative)
##
## 0 1
## 1694 90
prop.table(table(Doff.by.quarter.2$gram.negative))
##
## 0 1
## 0.94955157 0.05044843
# SCM quarter
table(Doff.by.quarter.2$delaval.SCM)
##
## 0 1
## 1529 372
prop.table(table(Doff.by.quarter.2$delaval.SCM))
##
## 0 1
## 0.8043135 0.1956865
# Prevalence IMI cow
table(Doff.by.cow.3$Contaminated.cow)
##
## 0 1
## 482 6
prop.table(table(Doff.by.cow.3$Contaminated.cow))
##
## 0 1
## 0.98770492 0.01229508
table(Doff.by.cow.3$IMI.cow)
##
## 0 1
## 98 384
prop.table(table(Doff.by.cow.3$IMI.cow))
##
## 0 1
## 0.2033195 0.7966805
table(Doff.by.cow.3$Staph.aureus.cow)
##
## 0 1
## 479 3
prop.table(table(Doff.by.cow.3$Staph.aureus.cow))
##
## 0 1
## 0.993775934 0.006224066
table(Doff.by.cow.3$CNS.cow)
##
## 0 1
## 202 280
prop.table(table(Doff.by.cow.3$CNS.cow))
##
## 0 1
## 0.4190871 0.5809129
table(Doff.by.cow.3$SSLO.cow)
##
## 0 1
## 192 290
prop.table(table(Doff.by.cow.3$SSLO.cow))
##
## 0 1
## 0.3983402 0.6016598
table(Doff.by.cow.3$gram.negative.cow)
##
## 0 1
## 404 78
prop.table(table(Doff.by.cow.3$gram.negative.cow))
##
## 0 1
## 0.8381743 0.1618257
#SCM cow
table(Doff.by.cow.3$delaval.SCM.CO.COW)
##
## 0 1
## 341 145
prop.table(table(Doff.by.cow.3$delaval.SCM.CO.COW))
##
## 0 1
## 0.7016461 0.2983539
# ---- C3 -----
# Prevalence IMI quarter
table(Pc.by.quarter.C3$Contaminated)
##
## 0 1
## 1595 90
prop.table(table(Pc.by.quarter.C3$Contaminated))
##
## 0 1
## 0.94658754 0.05341246
table(Pc.by.quarter.C3$IMI)
##
## 0 1
## 1050 545
prop.table(table(Pc.by.quarter.C3$IMI))
##
## 0 1
## 0.6583072 0.3416928
table(Pc.by.quarter.C3$Staph.aureus)
##
## 0 1
## 1593 2
prop.table(table(Pc.by.quarter.C3$Staph.aureus))
##
## 0 1
## 0.998746082 0.001253918
table(Pc.by.quarter.C3$CNS)
##
## 0 1
## 1298 297
prop.table(table(Pc.by.quarter.C3$CNS))
##
## 0 1
## 0.8137931 0.1862069
table(Pc.by.quarter.C3$SSLO)
##
## 0 1
## 1248 347
prop.table(table(Pc.by.quarter.C3$SSLO))
##
## 0 1
## 0.7824451 0.2175549
table(Pc.by.quarter.C3$gram.negative)
##
## 0 1
## 1520 75
prop.table(table(Pc.by.quarter.C3$gram.negative))
##
## 0 1
## 0.95297806 0.04702194
# SCM quarter
table(Pc.by.quarter.C3$delaval.SCM)
##
## 0 1
## 1314 366
prop.table(table(Pc.by.quarter.C3$delaval.SCM))
##
## 0 1
## 0.7821429 0.2178571
# Prevalence IMI cow
table(Pc.by.cow.C3$Contaminated.cow)
##
## 0 1
## 428 3
prop.table(table(Pc.by.cow.C3$Contaminated.cow))
##
## 0 1
## 0.993039443 0.006960557
table(Pc.by.cow.C3$IMI.cow)
##
## 0 1
## 115 313
prop.table(table(Pc.by.cow.C3$IMI.cow))
##
## 0 1
## 0.2686916 0.7313084
table(Pc.by.cow.C3$Staph.aureus.cow)
##
## 0 1
## 426 2
prop.table(table(Pc.by.cow.C3$Staph.aureus.cow))
##
## 0 1
## 0.995327103 0.004672897
table(Pc.by.cow.C3$CNS.cow)
##
## 0 1
## 219 209
prop.table(table(Pc.by.cow.C3$CNS.cow))
##
## 0 1
## 0.5116822 0.4883178
table(Pc.by.cow.C3$SSLO.cow)
##
## 0 1
## 196 232
prop.table(table(Pc.by.cow.C3$SSLO.cow))
##
## 0 1
## 0.4579439 0.5420561
table(Pc.by.cow.C3$gram.negative.cow)
##
## 0 1
## 362 66
prop.table(table(Pc.by.cow.C3$gram.negative.cow))
##
## 0 1
## 0.8457944 0.1542056
#SCM cow
table(Pc.by.cow.C3$delaval.SCM.CO.COW)
##
## 0 1
## 310 118
prop.table(table(Pc.by.cow.C3$delaval.SCM.CO.COW))
##
## 0 1
## 0.7242991 0.2757009
# ---- C5 -----
# Prevalence IMI quarter
table(Pc.by.quarter.C5$Contaminated)
##
## 0 1
## 1563 91
prop.table(table(Pc.by.quarter.C5$Contaminated))
##
## 0 1
## 0.94498186 0.05501814
table(Pc.by.quarter.C5$IMI)
##
## 0 1
## 1020 543
prop.table(table(Pc.by.quarter.C5$IMI))
##
## 0 1
## 0.6525912 0.3474088
table(Pc.by.quarter.C5$Staph.aureus)
##
## 0 1
## 1561 2
prop.table(table(Pc.by.quarter.C5$Staph.aureus))
##
## 0 1
## 0.998720409 0.001279591
table(Pc.by.quarter.C5$CNS)
##
## 0 1
## 1254 309
prop.table(table(Pc.by.quarter.C5$CNS))
##
## 0 1
## 0.8023033 0.1976967
table(Pc.by.quarter.C5$SSLO)
##
## 0 1
## 1225 338
prop.table(table(Pc.by.quarter.C5$SSLO))
##
## 0 1
## 0.7837492 0.2162508
table(Pc.by.quarter.C5$gram.negative)
##
## 0 1
## 1491 72
prop.table(table(Pc.by.quarter.C5$gram.negative))
##
## 0 1
## 0.95393474 0.04606526
# SCM quarter
table(Pc.by.quarter.C5$delaval.SCM)
##
## 0 1
## 1497 145
prop.table(table(Pc.by.quarter.C5$delaval.SCM))
##
## 0 1
## 0.91169306 0.08830694
# Prevalence IMI cow
table(Pc.by.cow.C5$Contaminated.cow)
##
## 0 1
## 421 3
prop.table(table(Pc.by.cow.C5$Contaminated.cow))
##
## 0 1
## 0.992924528 0.007075472
table(Pc.by.cow.C5$IMI.cow)
##
## 0 1
## 108 313
prop.table(table(Pc.by.cow.C5$IMI.cow))
##
## 0 1
## 0.2565321 0.7434679
table(Pc.by.cow.C5$Staph.aureus.cow)
##
## 0 1
## 419 2
prop.table(table(Pc.by.cow.C5$Staph.aureus.cow))
##
## 0 1
## 0.995249406 0.004750594
table(Pc.by.cow.C5$CNS.cow)
##
## 0 1
## 206 215
prop.table(table(Pc.by.cow.C5$CNS.cow))
##
## 0 1
## 0.4893112 0.5106888
table(Pc.by.cow.C5$SSLO.cow)
##
## 0 1
## 193 228
prop.table(table(Pc.by.cow.C5$SSLO.cow))
##
## 0 1
## 0.4584323 0.5415677
table(Pc.by.cow.C5$gram.negative.cow)
##
## 0 1
## 358 63
prop.table(table(Pc.by.cow.C5$gram.negative.cow))
##
## 0 1
## 0.8503563 0.1496437
#SCM cow
table(Pc.by.cow.C5$delaval.SCM.CO.COW)
##
## 0 1
## 357 63
prop.table(table(Pc.by.cow.C5$delaval.SCM.CO.COW))
##
## 0 1
## 0.85 0.15
# DSCC
table1(~log.SCC + term_diag + log.Neu + log.Lym + log.Mac + PERCENT01_N + PERCENT02_N + PERCENT03_N,data=Doff.by.quarter.2)
| Overall (N=1905) |
|
|---|---|
| log.SCC | |
| Mean (SD) | 4.36 (1.19) |
| Median [Min, Max] | 4.29 [1.10, 8.59] |
| Missing | 4 (0.2%) |
| term_diag | |
| Negative | 1563 (82.0%) |
| Positive | 327 (17.2%) |
| Missing | 15 (0.8%) |
| log.Neu | |
| Mean (SD) | 3.68 (1.26) |
| Median [Min, Max] | 3.50 [0.693, 9.34] |
| Missing | 15 (0.8%) |
| log.Lym | |
| Mean (SD) | 2.66 (1.22) |
| Median [Min, Max] | 2.56 [0, 8.04] |
| Missing | 15 (0.8%) |
| log.Mac | |
| Mean (SD) | 3.09 (1.42) |
| Median [Min, Max] | 2.94 [0, 8.58] |
| Missing | 15 (0.8%) |
| PERCENT01_N | |
| Mean (SD) | 50.3 (12.1) |
| Median [Min, Max] | 50.0 [13.1, 85.7] |
| Missing | 15 (0.8%) |
| PERCENT02_N | |
| Mean (SD) | 19.1 (8.14) |
| Median [Min, Max] | 17.8 [0, 60.0] |
| Missing | 15 (0.8%) |
| PERCENT03_N | |
| Mean (SD) | 30.6 (14.5) |
| Median [Min, Max] | 29.2 [0, 83.5] |
| Missing | 15 (0.8%) |
table1(~log.SCC + term_diag + log.Neu + log.Lym + log.Mac + PERCENT01_N + PERCENT02_N + PERCENT03_N,data=Pc.by.quarter.C3)
| Overall (N=1685) |
|
|---|---|
| log.SCC | |
| Mean (SD) | 4.79 (0.906) |
| Median [Min, Max] | 4.73 [1.79, 8.66] |
| Missing | 5 (0.3%) |
| term_diag | |
| Negative | 1291 (76.6%) |
| Positive | 394 (23.4%) |
| log.Neu | |
| Mean (SD) | 4.14 (0.970) |
| Median [Min, Max] | 4.04 [1.61, 9.43] |
| Missing | 1 (0.1%) |
| log.Lym | |
| Mean (SD) | 3.01 (0.946) |
| Median [Min, Max] | 2.94 [0, 7.22] |
| Missing | 1 (0.1%) |
| log.Mac | |
| Mean (SD) | 3.01 (1.08) |
| Median [Min, Max] | 2.89 [0, 8.99] |
| Missing | 1 (0.1%) |
| PERCENT01_N | |
| Mean (SD) | 58.9 (11.4) |
| Median [Min, Max] | 59.7 [20.2, 87.3] |
| Missing | 1 (0.1%) |
| PERCENT02_N | |
| Mean (SD) | 19.6 (5.98) |
| Median [Min, Max] | 19.2 [2.70, 48.3] |
| Missing | 1 (0.1%) |
| PERCENT03_N | |
| Mean (SD) | 21.4 (11.1) |
| Median [Min, Max] | 19.4 [1.89, 72.9] |
| Missing | 1 (0.1%) |
table1(~log.SCC + term_diag + log.Neu + log.Lym + log.Mac + PERCENT01_N + PERCENT02_N + PERCENT03_N,data=Pc.by.quarter.C5)
| Overall (N=1654) |
|
|---|---|
| log.SCC | |
| Mean (SD) | 4.15 (1.05) |
| Median [Min, Max] | 4.04 [1.39, 8.52] |
| Missing | 12 (0.7%) |
| term_diag | |
| Negative | 1504 (90.9%) |
| Positive | 143 (8.6%) |
| Missing | 7 (0.4%) |
| log.Neu | |
| Mean (SD) | 3.43 (1.11) |
| Median [Min, Max] | 3.26 [1.10, 10.2] |
| Missing | 7 (0.4%) |
| log.Lym | |
| Mean (SD) | 2.43 (1.08) |
| Median [Min, Max] | 2.30 [0, 8.17] |
| Missing | 7 (0.4%) |
| log.Mac | |
| Mean (SD) | 2.35 (1.21) |
| Median [Min, Max] | 2.20 [0, 9.13] |
| Missing | 7 (0.4%) |
| PERCENT01_N | |
| Mean (SD) | 56.2 (10.7) |
| Median [Min, Max] | 56.3 [13.8, 89.6] |
| Missing | 7 (0.4%) |
| PERCENT02_N | |
| Mean (SD) | 21.9 (8.17) |
| Median [Min, Max] | 21.3 [0, 61.5] |
| Missing | 7 (0.4%) |
| PERCENT03_N | |
| Mean (SD) | 21.8 (11.6) |
| Median [Min, Max] | 20.0 [0, 71.4] |
| Missing | 7 (0.4%) |
table1(~log.SCC.CO.COW + as.factor(Qscout.CO.COW) + log.TOTAL.NEU.CO.COW + log.TOTAL.LYM.CO.COW + log.TOTAL.MAC.CO.COW + PERCENT.NEU.CO.COW + PERCENT.LYM.CO.COW + PERCENT.MAC.CO.COW,data=Doff.by.cow.3)
| Overall (N=488) |
|
|---|---|
| log.SCC.CO.COW | |
| Mean (SD) | 4.68 (1.15) |
| Median [Min, Max] | 4.56 [1.79, 8.05] |
| Missing | 2 (0.4%) |
| as.factor(Qscout.CO.COW) | |
| 0 | 356 (73.0%) |
| 1 | 117 (24.0%) |
| Missing | 15 (3.1%) |
| log.TOTAL.NEU.CO.COW | |
| Mean (SD) | 4.03 (1.29) |
| Median [Min, Max] | 3.85 [1.39, 8.67] |
| Missing | 15 (3.1%) |
| log.TOTAL.LYM.CO.COW | |
| Mean (SD) | 2.93 (1.17) |
| Median [Min, Max] | 2.83 [0, 7.08] |
| Missing | 15 (3.1%) |
| log.TOTAL.MAC.CO.COW | |
| Mean (SD) | 3.49 (1.33) |
| Median [Min, Max] | 3.40 [0, 7.29] |
| Missing | 15 (3.1%) |
| PERCENT.NEU.CO.COW | |
| Mean (SD) | 50.7 (12.8) |
| Median [Min, Max] | 51.1 [15.7, 122] |
| Missing | 15 (3.1%) |
| PERCENT.LYM.CO.COW | |
| Mean (SD) | 17.7 (7.39) |
| Median [Min, Max] | 16.9 [3.54, 69.0] |
| Missing | 15 (3.1%) |
| PERCENT.MAC.CO.COW | |
| Mean (SD) | 31.9 (14.3) |
| Median [Min, Max] | 29.9 [3.41, 74.5] |
| Missing | 15 (3.1%) |
table1(~log.SCC.CO.COW + as.factor(Qscout.CO.COW) + log.TOTAL.NEU.CO.COW + log.TOTAL.LYM.CO.COW + log.TOTAL.MAC.CO.COW + PERCENT.NEU.CO.COW + PERCENT.LYM.CO.COW + PERCENT.MAC.CO.COW,data=Pc.by.cow.C3)
| Overall (N=431) |
|
|---|---|
| log.SCC.CO.COW | |
| Mean (SD) | 5.00 (1.00) |
| Median [Min, Max] | 4.88 [2.83, 8.25] |
| Missing | 3 (0.7%) |
| as.factor(Qscout.CO.COW) | |
| 0 | 317 (73.5%) |
| 1 | 113 (26.2%) |
| Missing | 1 (0.2%) |
| log.TOTAL.NEU.CO.COW | |
| Mean (SD) | 4.26 (1.04) |
| Median [Min, Max] | 4.13 [2.20, 8.66] |
| Missing | 1 (0.2%) |
| log.TOTAL.LYM.CO.COW | |
| Mean (SD) | 3.16 (0.983) |
| Median [Min, Max] | 3.07 [0, 6.92] |
| Missing | 1 (0.2%) |
| log.TOTAL.MAC.CO.COW | |
| Mean (SD) | 3.29 (1.12) |
| Median [Min, Max] | 3.18 [0, 8.32] |
| Missing | 1 (0.2%) |
| PERCENT.NEU.CO.COW | |
| Mean (SD) | 57.0 (11.8) |
| Median [Min, Max] | 57.4 [21.2, 87.0] |
| Missing | 1 (0.2%) |
| PERCENT.LYM.CO.COW | |
| Mean (SD) | 19.3 (5.88) |
| Median [Min, Max] | 19.2 [5.08, 51.1] |
| Missing | 1 (0.2%) |
| PERCENT.MAC.CO.COW | |
| Mean (SD) | 23.7 (11.6) |
| Median [Min, Max] | 22.0 [3.51, 73.1] |
| Missing | 1 (0.2%) |
table1(~log.SCC.CO.COW + as.factor(Qscout.CO.COW) + log.TOTAL.NEU.CO.COW + log.TOTAL.LYM.CO.COW + log.TOTAL.MAC.CO.COW + PERCENT.NEU.CO.COW + PERCENT.LYM.CO.COW + PERCENT.MAC.CO.COW,data=Pc.by.cow.C5)
| Overall (N=424) |
|
|---|---|
| log.SCC.CO.COW | |
| Mean (SD) | 4.46 (1.18) |
| Median [Min, Max] | 4.23 [1.39, 8.57] |
| Missing | 4 (0.9%) |
| as.factor(Qscout.CO.COW) | |
| 0 | 366 (86.3%) |
| 1 | 56 (13.2%) |
| Missing | 2 (0.5%) |
| log.TOTAL.NEU.CO.COW | |
| Mean (SD) | 3.68 (1.27) |
| Median [Min, Max] | 3.40 [1.39, 8.95] |
| Missing | 2 (0.5%) |
| log.TOTAL.LYM.CO.COW | |
| Mean (SD) | 2.64 (1.18) |
| Median [Min, Max] | 2.48 [0, 7.12] |
| Missing | 2 (0.5%) |
| log.TOTAL.MAC.CO.COW | |
| Mean (SD) | 2.67 (1.34) |
| Median [Min, Max] | 2.40 [0, 7.61] |
| Missing | 2 (0.5%) |
| PERCENT.NEU.CO.COW | |
| Mean (SD) | 56.2 (11.1) |
| Median [Min, Max] | 56.5 [18.8, 86.7] |
| Missing | 2 (0.5%) |
| PERCENT.LYM.CO.COW | |
| Mean (SD) | 20.8 (7.24) |
| Median [Min, Max] | 20.0 [0, 44.8] |
| Missing | 2 (0.5%) |
| PERCENT.MAC.CO.COW | |
| Mean (SD) | 23.0 (11.7) |
| Median [Min, Max] | 21.2 [2.00, 71.9] |
| Missing | 2 (0.5%) |
# Best cut-off using ROC analysis
# Set a seed for reproducibility
set.seed(123)
# Dry-off
# ------ Cow level -------
# Reference IMI
# SCC IMI COW
SCC.IMI.CO <- cutpointr(Doff.by.cow.3, log.SCC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(SCC.IMI.CO)
## Method: maximize_metric
## Predictor: log.SCC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5847 480 382 98
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.7095 1.1886 0.5354 0.4948 0.6939 0.863 0.2605 189
## fn fp tn
## 193 30 68
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 1.791759 2.944439 3.912023 4.564348 4.681304 5.399246 6.877693 8.05484
## 0 1.945910 2.988038 3.719596 4.369127 4.408228 4.998861 6.002250 8.05484
## 1 1.791759 2.947004 3.956006 4.691348 4.751360 5.499209 7.009273 7.99699
## SD NAs
## 1.1466263 0
## 0.9963544 0
## 1.1730676 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.53 4.28 4.71 4.71 4.77 4.74 5.55 6.28 0.34 0
## AUC_b 0.47 0.54 0.56 0.59 0.59 0.61 0.64 0.68 0.03 0
## AUC_oob 0.43 0.52 0.56 0.58 0.58 0.61 0.65 0.70 0.04 0
## sum_sens_spec_b 1.02 1.12 1.16 1.20 1.20 1.23 1.28 1.39 0.05 0
## sum_sens_spec_oob 0.88 1.00 1.08 1.14 1.14 1.19 1.26 1.37 0.08 0
## acc_b 0.24 0.39 0.52 0.54 0.53 0.56 0.63 0.78 0.07 0
## acc_oob 0.25 0.36 0.49 0.52 0.51 0.55 0.60 0.73 0.07 0
## sensitivity_b 0.09 0.25 0.46 0.49 0.48 0.52 0.66 0.89 0.11 0
## sensitivity_oob 0.06 0.23 0.44 0.48 0.47 0.51 0.65 0.85 0.11 0
## specificity_b 0.22 0.54 0.68 0.72 0.72 0.76 0.90 1.00 0.10 0
## specificity_oob 0.14 0.41 0.62 0.68 0.67 0.74 0.87 1.00 0.13 0
## cohens_kappa_b 0.01 0.07 0.10 0.12 0.12 0.15 0.18 0.26 0.03 0
## cohens_kappa_oob -0.10 0.00 0.05 0.08 0.08 0.12 0.16 0.25 0.05 0
## ppv_b 0.78 0.83 0.85 0.87 0.87 0.89 0.92 1.00 0.03 0
## ppv_oob 0.71 0.79 0.82 0.85 0.85 0.88 0.91 1.00 0.04 0
## npv_b 0.17 0.22 0.25 0.26 0.26 0.28 0.31 0.40 0.03 0
## npv_oob 0.12 0.19 0.22 0.24 0.24 0.27 0.30 0.38 0.04 0
# ROC plot
plot(SCC.IMI.CO)
# Youden index plot
plot_metric(SCC.IMI.CO)
# NEU IMI COW
NEU.IMI.CO <- cutpointr(Doff.by.cow.3, log.TOTAL.NEU.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.IMI.CO)
## Method: maximize_metric
## Predictor: log.TOTAL.NEU.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.6038 468 371 97
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 4.2767 1.19 0.4786 0.3962 0.7938 0.8802 0.2558
## tp fn fp tn
## 147 224 20 77
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.386294 2.302585 3.124381 3.839394 4.025560 4.736198 6.424920
## 0 1.791759 2.448442 2.890372 3.433987 3.664973 4.204693 5.304821
## 1 1.386294 2.302585 3.218876 3.931826 4.119838 4.770685 6.810725
## Max. SD NAs
## 8.674026 1.286657 0
## 8.176673 1.018763 0
## 8.674026 1.333119 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.00 3.09 3.40 4.06 3.84 4.28 4.60 5.95 0.51 0
## AUC_b 0.50 0.55 0.58 0.60 0.60 0.62 0.65 0.69 0.03 0
## AUC_oob 0.47 0.53 0.58 0.61 0.60 0.63 0.67 0.72 0.04 0
## sum_sens_spec_b 1.05 1.14 1.19 1.22 1.22 1.25 1.29 1.37 0.05 0
## sum_sens_spec_oob 0.87 1.02 1.09 1.13 1.13 1.18 1.24 1.37 0.07 0
## acc_b 0.27 0.44 0.49 0.56 0.58 0.67 0.73 0.78 0.10 0
## acc_oob 0.24 0.41 0.46 0.53 0.55 0.64 0.71 0.78 0.10 0
## sensitivity_b 0.09 0.34 0.41 0.50 0.56 0.71 0.81 0.87 0.17 0
## sensitivity_oob 0.06 0.31 0.39 0.49 0.54 0.70 0.81 0.86 0.17 0
## specificity_b 0.28 0.39 0.51 0.70 0.66 0.81 0.87 1.00 0.17 0
## specificity_oob 0.13 0.31 0.42 0.59 0.59 0.76 0.85 1.00 0.19 0
## cohens_kappa_b 0.03 0.08 0.12 0.15 0.15 0.18 0.23 0.35 0.05 0
## cohens_kappa_oob -0.11 0.01 0.06 0.09 0.09 0.12 0.18 0.31 0.05 0
## ppv_b 0.78 0.82 0.85 0.87 0.87 0.89 0.92 1.00 0.03 0
## ppv_oob 0.72 0.78 0.82 0.84 0.84 0.87 0.91 1.00 0.04 0
## npv_b 0.19 0.23 0.26 0.29 0.29 0.32 0.37 0.47 0.04 0
## npv_oob 0.11 0.19 0.23 0.25 0.26 0.28 0.34 0.49 0.04 0
# ROC plot
plot(NEU.IMI.CO)
# Youden index plot
plot_metric(NEU.IMI.CO)
# %NEU IMI COW
PER.NEU.IMI.CO <- cutpointr(Doff.by.cow.3, PERCENT.NEU.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.IMI.CO)
## Method: maximize_metric
## Predictor: PERCENT.NEU.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5488 468 371 97
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 51.63 1.1329 0.5299 0.504 0.6289 0.8386 0.249 187
## fn fp tn
## 184 36 61
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 15.69 29.2245 41.6575 51.14 50.68026 59.58 70.399 122.00 12.80270
## 0 19.90 29.2000 41.4800 49.33 49.41639 56.64 68.902 122.00 13.75413
## 1 15.69 29.2650 41.6850 51.69 51.01070 60.82 71.055 83.52 12.54066
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 31.23 45.90 51.63 51.79 53.55 57.63 62.38 65.30 5.49
## AUC_b 0.44 0.50 0.53 0.55 0.55 0.57 0.60 0.65 0.03
## AUC_oob 0.42 0.48 0.52 0.55 0.55 0.58 0.62 0.69 0.04
## sum_sens_spec_b 1.02 1.08 1.12 1.15 1.15 1.18 1.23 1.33 0.05
## sum_sens_spec_oob 0.80 0.95 1.02 1.07 1.07 1.12 1.18 1.33 0.07
## acc_b 0.28 0.35 0.43 0.53 0.50 0.55 0.62 0.80 0.09
## acc_oob 0.24 0.33 0.40 0.50 0.48 0.53 0.58 0.79 0.09
## sensitivity_b 0.12 0.21 0.33 0.49 0.45 0.53 0.65 0.95 0.15
## sensitivity_oob 0.10 0.19 0.30 0.47 0.44 0.52 0.63 0.96 0.15
## specificity_b 0.13 0.49 0.63 0.68 0.70 0.81 0.91 0.98 0.14
## specificity_oob 0.03 0.34 0.55 0.62 0.63 0.74 0.89 0.97 0.17
## cohens_kappa_b 0.01 0.04 0.07 0.09 0.09 0.12 0.15 0.22 0.03
## cohens_kappa_oob -0.18 -0.04 0.01 0.04 0.04 0.07 0.12 0.22 0.05
## ppv_b 0.76 0.81 0.84 0.86 0.86 0.88 0.91 0.97 0.03
## ppv_oob 0.70 0.76 0.80 0.82 0.82 0.85 0.89 0.97 0.04
## npv_b 0.18 0.21 0.23 0.25 0.25 0.27 0.31 0.46 0.03
## npv_oob 0.03 0.17 0.20 0.23 0.23 0.25 0.28 0.35 0.04
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.IMI.CO)
# Youden index plot
plot_metric(PER.NEU.IMI.CO)
# LYM IMI COW
LYM.IMI.CO <- cutpointr(Doff.by.cow.3, log.TOTAL.LYM.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.IMI.CO)
## Method: maximize_metric
## Predictor: log.TOTAL.LYM.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.6116 468 371 97
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 2.7726 1.2209 0.5876 0.5714 0.6495 0.8618 0.2838
## tp fn fp tn
## 212 159 34 63
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.0000000 1.098612 2.079442 2.802901 2.918222 3.644080 4.904848
## 0 0.6931472 1.098612 1.945910 2.484907 2.593755 3.218876 4.256046
## 1 0.0000000 1.098612 2.197225 2.944439 3.003056 3.749435 5.100869
## Max. SD NAs
## 7.082549 1.1648283 0
## 6.786717 0.9968735 0
## 7.082549 1.1915860 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.08 2.64 2.64 2.71 2.76 2.77 3.53 4.50 0.27 0
## AUC_b 0.52 0.56 0.59 0.61 0.61 0.63 0.66 0.71 0.03 0
## AUC_oob 0.45 0.54 0.58 0.61 0.61 0.64 0.68 0.76 0.04 0
## sum_sens_spec_b 1.07 1.15 1.20 1.23 1.24 1.27 1.32 1.42 0.05 0
## sum_sens_spec_oob 0.92 1.05 1.13 1.19 1.18 1.24 1.31 1.44 0.08 0
## acc_b 0.29 0.44 0.59 0.61 0.60 0.63 0.66 0.78 0.06 0
## acc_oob 0.28 0.41 0.57 0.59 0.58 0.62 0.65 0.75 0.06 0
## sensitivity_b 0.12 0.34 0.57 0.60 0.59 0.63 0.68 0.86 0.09 0
## sensitivity_oob 0.10 0.30 0.56 0.59 0.58 0.63 0.68 0.85 0.10 0
## specificity_b 0.34 0.53 0.60 0.64 0.65 0.68 0.86 1.00 0.09 0
## specificity_oob 0.16 0.45 0.55 0.61 0.61 0.67 0.81 1.00 0.11 0
## cohens_kappa_b 0.04 0.09 0.14 0.17 0.16 0.19 0.23 0.36 0.04 0
## cohens_kappa_oob -0.08 0.03 0.09 0.13 0.13 0.17 0.22 0.30 0.06 0
## ppv_b 0.79 0.83 0.85 0.87 0.87 0.88 0.91 1.00 0.03 0
## ppv_oob 0.73 0.80 0.83 0.85 0.85 0.87 0.90 1.00 0.03 0
## npv_b 0.17 0.24 0.27 0.29 0.29 0.32 0.35 0.50 0.03 0
## npv_oob 0.15 0.21 0.24 0.27 0.27 0.30 0.34 0.41 0.04 0
# ROC plot
plot(LYM.IMI.CO)
# Youden index plot
plot_metric(LYM.IMI.CO)
# %LYM IMI COW
PER.LYM.IMI.CO <- cutpointr(Doff.by.cow.3, PERCENT.LYM.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.IMI.CO)
## Method: maximize_metric
## Predictor: PERCENT.LYM.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5002 468 371 97
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 15.2 1.0596 0.5684 0.5957 0.4639 0.8095 0.2308
## tp fn fp tn
## 221 150 52 45
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 3.54 8.0935 12.7075 16.88 17.64716 21.125 30.360 69.0 7.389449 0
## 0 4.94 8.6400 12.7500 16.67 17.91680 20.600 31.104 69.0 8.508381 0
## 1 3.54 8.0950 12.7050 16.89 17.57666 21.140 29.915 54.5 7.078988 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 5.56 9.07 14.61 15.20 Inf 15.79 24.00 Inf NaN 0
## AUC_b 0.38 0.45 0.48 0.50 0.50 0.52 0.56 0.60 0.03 0
## AUC_oob 0.36 0.43 0.47 0.50 0.50 0.53 0.57 0.67 0.04 0
## sum_sens_spec_b 0.94 1.02 1.05 1.08 1.09 1.12 1.17 1.25 0.05 0
## sum_sens_spec_oob 0.72 0.88 0.94 0.98 0.98 1.02 1.09 1.22 0.07 0
## acc_b 0.18 0.32 0.54 0.58 0.57 0.62 0.78 0.82 0.13 0
## acc_oob 0.15 0.27 0.50 0.55 0.53 0.59 0.76 0.83 0.14 0
## sensitivity_b 0.00 0.17 0.55 0.60 0.58 0.66 0.95 1.00 0.23 0
## sensitivity_oob 0.00 0.14 0.51 0.58 0.56 0.64 0.94 1.00 0.23 0
## specificity_b 0.01 0.10 0.42 0.50 0.50 0.58 0.89 1.00 0.23 0
## specificity_oob 0.00 0.03 0.31 0.42 0.42 0.52 0.83 1.00 0.23 0
## cohens_kappa_b -0.06 0.01 0.04 0.06 0.06 0.09 0.13 0.19 0.03 0
## cohens_kappa_oob -0.23 -0.09 -0.04 -0.01 -0.01 0.02 0.07 0.14 0.05 0
## ppv_b 0.74 0.78 0.80 0.82 0.83 0.84 0.88 1.00 0.03 4
## ppv_oob 0.00 0.71 0.76 0.79 0.78 0.81 0.84 1.00 0.06 5
## npv_b 0.15 0.20 0.23 0.25 0.26 0.27 0.35 1.00 0.06 0
## npv_oob 0.00 0.11 0.17 0.20 0.19 0.22 0.26 0.45 0.05 8
# ROC plot
plot(PER.LYM.IMI.CO)
## Warning: Removed 4 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(PER.LYM.IMI.CO)
# MAC IMI COW
MAC.IMI.CO <- cutpointr(Doff.by.cow.3, log.TOTAL.MAC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.IMI.CO)
## Method: maximize_metric
## Predictor: log.TOTAL.MAC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5733 468 371 97
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.0604 1.1388 0.438 0.345 0.7938 0.8649 0.2406 128
## fn fp tn
## 243 20 77
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 1.609438 2.564949 3.401197 3.484217 4.406719 5.743569 7.289611
## 0 0 1.328758 2.197225 3.135494 3.211078 3.988984 5.257283 6.419995
## 1 0 1.609438 2.564949 3.433987 3.555631 4.521789 5.791487 7.289611
## SD NAs
## 1.335529 0
## 1.226225 0
## 1.355151 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 1.79 2.64 3.22 3.74 3.75 4.14 4.61 5.32 0.56 0
## AUC_b 0.47 0.52 0.55 0.57 0.57 0.59 0.62 0.68 0.03 0
## AUC_oob 0.45 0.51 0.54 0.57 0.57 0.60 0.64 0.72 0.04 0
## sum_sens_spec_b 1.04 1.09 1.14 1.17 1.17 1.20 1.25 1.33 0.05 0
## sum_sens_spec_oob 0.79 0.97 1.04 1.08 1.08 1.13 1.19 1.32 0.07 0
## acc_b 0.28 0.37 0.44 0.49 0.51 0.58 0.66 0.78 0.09 0
## acc_oob 0.21 0.35 0.41 0.46 0.47 0.54 0.63 0.74 0.09 0
## sensitivity_b 0.11 0.24 0.35 0.42 0.45 0.57 0.74 0.93 0.15 0
## sensitivity_oob 0.06 0.22 0.32 0.39 0.43 0.55 0.71 0.92 0.15 0
## specificity_b 0.16 0.41 0.62 0.76 0.72 0.83 0.90 0.99 0.15 0
## specificity_oob 0.05 0.29 0.54 0.69 0.65 0.78 0.88 1.00 0.17 0
## cohens_kappa_b 0.02 0.05 0.08 0.10 0.10 0.13 0.17 0.23 0.03 0
## cohens_kappa_oob -0.16 -0.02 0.02 0.05 0.05 0.07 0.12 0.20 0.04 0
## ppv_b 0.76 0.82 0.85 0.87 0.87 0.89 0.92 0.99 0.03 0
## ppv_oob 0.68 0.77 0.80 0.83 0.83 0.86 0.90 1.00 0.04 0
## npv_b 0.16 0.21 0.24 0.26 0.26 0.28 0.31 0.45 0.03 0
## npv_oob 0.09 0.17 0.21 0.23 0.23 0.25 0.28 0.38 0.03 0
# ROC plot
plot(MAC.IMI.CO)
# Youden index plot
plot_metric(MAC.IMI.CO)
# %MAC IMI COW
PER.MAC.IMI.CO <- cutpointr(Doff.by.cow.3, PERCENT.MAC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.IMI.CO)
## Method: maximize_metric
## Predictor: PERCENT.MAC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5488 468 97 371
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 43.55 1.0995 0.6966 0.299 0.8005 0.2816 0.8137 29
## fn fp tn
## 68 74 297
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 3.41 12.5175 20.8225 29.93 31.98408 41.53 58.0975 74.51 14.27458
## 0 4.76 12.6560 21.5000 31.11 34.16928 44.59 60.4840 72.50 15.35945
## 1 3.41 12.5250 20.2800 29.55 31.41275 41.24 55.3750 74.51 13.94252
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 10.00 19.12 27.80 36.84 36.23 43.94 52.78 65.80 10.22
## AUC_b 0.43 0.49 0.53 0.55 0.55 0.57 0.60 0.66 0.03
## AUC_oob 0.40 0.48 0.52 0.55 0.55 0.58 0.62 0.70 0.04
## sum_sens_spec_b 0.99 1.07 1.10 1.13 1.13 1.16 1.21 1.30 0.04
## sum_sens_spec_oob 0.76 0.92 0.98 1.02 1.02 1.07 1.12 1.23 0.06
## acc_b 0.19 0.37 0.51 0.63 0.61 0.72 0.78 0.83 0.13
## acc_oob 0.23 0.33 0.47 0.58 0.57 0.69 0.75 0.82 0.13
## sensitivity_b 0.05 0.18 0.31 0.47 0.50 0.66 0.88 1.00 0.22
## sensitivity_oob 0.00 0.10 0.23 0.38 0.41 0.56 0.81 0.97 0.22
## specificity_b 0.03 0.24 0.48 0.67 0.64 0.82 0.93 0.99 0.22
## specificity_oob 0.02 0.21 0.45 0.63 0.62 0.81 0.92 0.99 0.22
## cohens_kappa_b 0.00 0.04 0.08 0.10 0.11 0.14 0.19 0.27 0.04
## cohens_kappa_oob -0.16 -0.06 -0.01 0.02 0.02 0.05 0.11 0.21 0.05
## ppv_b 0.16 0.21 0.24 0.28 0.29 0.32 0.41 0.73 0.06
## ppv_oob 0.00 0.15 0.19 0.22 0.23 0.25 0.32 0.56 0.06
## npv_b 0.76 0.79 0.82 0.83 0.84 0.85 0.89 1.00 0.03
## npv_oob 0.62 0.74 0.78 0.80 0.80 0.82 0.85 0.94 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.MAC.IMI.CO)
# Youden index plot
plot_metric(PER.MAC.IMI.CO)
# Summary of results when using IMI as reference
print(c("Optimal SCC:", exp(SCC.IMI.CO$optimal_cutpoint), SCC.IMI.CO$sensitivity, SCC.IMI.CO$specificity, SCC.IMI.CO$ppv, SCC.IMI.CO$npv, SCC.IMI.CO$AUC))
## sensitivity specificity
## "Optimal SCC:" "111" "0.494764397905759" "0.693877551020408"
##
## "0.863013698630137" "0.260536398467433" "0.584731274708836"
print(c("Optimal n NEU:", exp(NEU.IMI.CO$optimal_cutpoint), NEU.IMI.CO$sensitivity, NEU.IMI.CO$specificity, NEU.IMI.CO$ppv, NEU.IMI.CO$npv, NEU.IMI.CO$AUC))
## sensitivity specificity
## "Optimal n NEU:" "72" "0.39622641509434" "0.793814432989691"
##
## "0.880239520958084" "0.255813953488372" "0.603815266624059"
print(c("Optimal %NEU:", PER.NEU.IMI.CO$optimal_cutpoint, PER.NEU.IMI.CO$sensitivity, PER.NEU.IMI.CO$specificity, PER.NEU.IMI.CO$ppv, PER.NEU.IMI.CO$npv, PER.NEU.IMI.CO$AUC))
## sensitivity specificity
## "Optimal %NEU:" "51.63" "0.504043126684636" "0.628865979381443"
##
## "0.838565022421525" "0.248979591836735" "0.548823186150554"
print(c("Optimal n LYM:", exp(LYM.IMI.CO$optimal_cutpoint), LYM.IMI.CO$sensitivity, LYM.IMI.CO$specificity, LYM.IMI.CO$ppv, LYM.IMI.CO$npv, LYM.IMI.CO$AUC))
## sensitivity specificity
## "Optimal n LYM:" "16" "0.571428571428571" "0.649484536082474"
##
## "0.861788617886179" "0.283783783783784" "0.611568066246144"
print(c("Optimal %LYM:", PER.LYM.IMI.CO$optimal_cutpoint, PER.LYM.IMI.CO$sensitivity, PER.LYM.IMI.CO$specificity, PER.LYM.IMI.CO$ppv, PER.LYM.IMI.CO$npv, PER.LYM.IMI.CO$AUC))
## sensitivity specificity
## "Optimal %LYM:" "15.2" "0.595687331536388" "0.463917525773196"
##
## "0.80952380952381" "0.230769230769231" "0.50015283296746"
print(c("Optimal n MAC:", exp(MAC.IMI.CO$optimal_cutpoint), MAC.IMI.CO$sensitivity, MAC.IMI.CO$specificity, MAC.IMI.CO$ppv, MAC.IMI.CO$npv, MAC.IMI.CO$AUC))
## sensitivity specificity
## "Optimal n MAC:" "58" "0.345013477088949" "0.793814432989691"
##
## "0.864864864864865" "0.240625" "0.573304248756495"
print(c("Optimal %MAC:", PER.MAC.IMI.CO$optimal_cutpoint, PER.MAC.IMI.CO$sensitivity, PER.MAC.IMI.CO$specificity, PER.MAC.IMI.CO$ppv, PER.MAC.IMI.CO$npv, PER.MAC.IMI.CO$AUC))
## sensitivity specificity
## "Optimal %MAC:" "43.55" "0.298969072164948" "0.800539083557951"
##
## "0.281553398058252" "0.813698630136986" "0.548795398338289"
# CI using bp
# SCC
SCC.IMI.CO_optimal_cutpoint <- boot_ci(SCC.IMI.CO, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
SCC.IMI.CO_lower_ci <- subset(SCC.IMI.CO_optimal_cutpoint,SCC.IMI.CO_optimal_cutpoint$quantile==0.025)$values
exp(SCC.IMI.CO_lower_ci)
## [1] 64.92326
SCC.IMI.CO_upper_ci <- subset(SCC.IMI.CO_optimal_cutpoint,SCC.IMI.CO_optimal_cutpoint$quantile==0.975)$values
exp(SCC.IMI.CO_upper_ci)
## [1] 279
boot_ci(SCC.IMI.CO, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.220
## 2 0.975 0.701
boot_ci(SCC.IMI.CO, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.465
## 2 0.975 0.931
boot_ci(SCC.IMI.CO, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.822
## 2 0.975 0.931
boot_ci(SCC.IMI.CO, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.208
## 2 0.975 0.324
boot_ci(SCC.IMI.CO, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.526
## 2 0.975 0.645
# Number neu
NEU.IMI.CO_optimal_cutpoint <- boot_ci(NEU.IMI.CO, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.IMI.CO_lower_ci <- subset(NEU.IMI.CO_optimal_cutpoint,NEU.IMI.CO_optimal_cutpoint$quantile==0.025)$values
exp(NEU.IMI.CO_lower_ci)
## [1] 22
NEU.IMI.CO_upper_ci <- subset(NEU.IMI.CO_optimal_cutpoint,NEU.IMI.CO_optimal_cutpoint$quantile==0.975)$values
exp(NEU.IMI.CO_upper_ci)
## [1] 103
boot_ci(NEU.IMI.CO, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.310
## 2 0.975 0.826
boot_ci(NEU.IMI.CO, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.370
## 2 0.975 0.892
boot_ci(NEU.IMI.CO, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.813
## 2 0.975 0.933
boot_ci(NEU.IMI.CO, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.220
## 2 0.975 0.386
boot_ci(NEU.IMI.CO, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.544
## 2 0.975 0.661
# Percent neu
PER.NEU.IMI.CO_optimal_cutpoint <- boot_ci(PER.NEU.IMI.CO, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.IMI.CO_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 36.8
## 2 0.975 64.0
PER.NEU.IMI.CO_lower_ci <- subset(PER.NEU.IMI.CO_optimal_cutpoint,PER.NEU.IMI.CO_optimal_cutpoint$quantile==0.025)$values
PER.NEU.IMI.CO_upper_ci <- subset(PER.NEU.IMI.CO_optimal_cutpoint,PER.NEU.IMI.CO_optimal_cutpoint$quantile==0.975)$values
boot_ci(PER.NEU.IMI.CO, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.192
## 2 0.975 0.876
boot_ci(PER.NEU.IMI.CO, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.257
## 2 0.975 0.931
boot_ci(PER.NEU.IMI.CO, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.802
## 2 0.975 0.928
boot_ci(PER.NEU.IMI.CO, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.201
## 2 0.975 0.329
boot_ci(PER.NEU.IMI.CO, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.488
## 2 0.975 0.613
# Number lym
LYM.IMI.CO_optimal_cutpoint <- boot_ci(LYM.IMI.CO, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.IMI.CO_lower_ci <- subset(LYM.IMI.CO_optimal_cutpoint,LYM.IMI.CO_optimal_cutpoint$quantile==0.025)$values
exp(LYM.IMI.CO_lower_ci)
## [1] 11
LYM.IMI.CO_upper_ci <- subset(LYM.IMI.CO_optimal_cutpoint,LYM.IMI.CO_optimal_cutpoint$quantile==0.975)$values
exp(LYM.IMI.CO_upper_ci)
## [1] 41
boot_ci(LYM.IMI.CO, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.268
## 2 0.975 0.710
boot_ci(LYM.IMI.CO, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.483
## 2 0.975 0.913
boot_ci(LYM.IMI.CO, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.821
## 2 0.975 0.922
boot_ci(LYM.IMI.CO, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.228
## 2 0.975 0.362
boot_ci(LYM.IMI.CO, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.553
## 2 0.975 0.674
# Percent lym
PER.LYM.IMI.CO_optimal_cutpoint <- boot_ci(PER.LYM.IMI.CO, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.IMI.CO_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 7.79
## 2 0.975 31.4
PER.LYM.IMI.CO_lower_ci <- subset(PER.LYM.IMI.CO_optimal_cutpoint,PER.LYM.IMI.CO_optimal_cutpoint$quantile==0.025)$values
PER.LYM.IMI.CO_upper_ci <- subset(PER.LYM.IMI.CO_optimal_cutpoint,PER.LYM.IMI.CO_optimal_cutpoint$quantile==0.975)$values
boot_ci(PER.LYM.IMI.CO, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0413
## 2 0.975 0.968
boot_ci(PER.LYM.IMI.CO, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0638
## 2 0.975 0.979
boot_ci(PER.LYM.IMI.CO, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.774
## 2 0.975 0.905
boot_ci(PER.LYM.IMI.CO, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.193
## 2 0.975 0.4
boot_ci(PER.LYM.IMI.CO, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.433
## 2 0.975 0.567
# Number mac
MAC.IMI.CO_optimal_cutpoint <- boot_ci(MAC.IMI.CO, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.IMI.CO_lower_ci <- subset(MAC.IMI.CO_optimal_cutpoint,MAC.IMI.CO_optimal_cutpoint$quantile==0.025)$values
exp(MAC.IMI.CO_lower_ci)
## [1] 10
MAC.IMI.CO_upper_ci <- subset(MAC.IMI.CO_optimal_cutpoint,MAC.IMI.CO_optimal_cutpoint$quantile==0.975)$values
exp(MAC.IMI.CO_upper_ci)
## [1] 124
boot_ci(MAC.IMI.CO, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.214
## 2 0.975 0.816
boot_ci(MAC.IMI.CO, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.330
## 2 0.975 0.925
boot_ci(MAC.IMI.CO, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.808
## 2 0.975 0.929
boot_ci(MAC.IMI.CO, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.205
## 2 0.975 0.329
boot_ci(MAC.IMI.CO, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.507
## 2 0.975 0.633
# Percent mac
PER.MAC.IMI.CO_optimal_cutpoint <- boot_ci(PER.MAC.IMI.CO, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.IMI.CO_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 19.1
## 2 0.975 55
PER.MAC.IMI.CO_lower_ci <- subset(PER.MAC.IMI.CO_optimal_cutpoint,PER.MAC.IMI.CO_optimal_cutpoint$quantile==0.025)$values
PER.MAC.IMI.CO_upper_ci <- subset(PER.MAC.IMI.CO_optimal_cutpoint,PER.MAC.IMI.CO_optimal_cutpoint$quantile==0.975)$values
boot_ci(PER.MAC.IMI.CO, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.139
## 2 0.975 0.898
boot_ci(PER.MAC.IMI.CO, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.216
## 2 0.975 0.947
boot_ci(PER.MAC.IMI.CO, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.205
## 2 0.975 0.441
boot_ci(PER.MAC.IMI.CO, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.786
## 2 0.975 0.900
boot_ci(PER.MAC.IMI.CO, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.482
## 2 0.975 0.615
# Prevalence
# True prevalence
table(Doff.by.cow.3$IMI.cow)
##
## 0 1
## 98 384
prop.table(table(Doff.by.cow.3$IMI.cow))
##
## 0 1
## 0.2033195 0.7966805
#Apparent prevalence
# ---- SCC ----
# optimal cut-off
optimal_scc_doff_IMI_cow <- SCC.IMI.CO$optimal_cutpoint
table(Doff.by.cow.3$SCC.CO.COW > exp(optimal_scc_doff_IMI_cow))
##
## FALSE TRUE
## 264 222
prop.table(table(Doff.by.cow.3$SCC.CO.COW > exp(optimal_scc_doff_IMI_cow)))
##
## FALSE TRUE
## 0.5432099 0.4567901
# confidence intervals
table(Doff.by.cow.3$SCC.CO.COW > exp(SCC.IMI.CO_lower_ci))
##
## FALSE TRUE
## 168 318
prop.table(table(Doff.by.cow.3$SCC.CO.COW > exp(SCC.IMI.CO_lower_ci)))
##
## FALSE TRUE
## 0.345679 0.654321
table(Doff.by.cow.3$SCC.CO.COW > exp(SCC.IMI.CO_upper_ci))
##
## FALSE TRUE
## 392 94
prop.table(table(Doff.by.cow.3$SCC.CO.COW >exp(SCC.IMI.CO_upper_ci)))
##
## FALSE TRUE
## 0.8065844 0.1934156
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_doff_IMI_cow <- NEU.IMI.CO$optimal_cutpoint
table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(optimal_neu_doff_IMI_cow))
##
## FALSE TRUE
## 304 169
prop.table(table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(optimal_neu_doff_IMI_cow)))
##
## FALSE TRUE
## 0.6427061 0.3572939
# confidence intervals
table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(NEU.IMI.CO_lower_ci))
##
## FALSE TRUE
## 117 356
prop.table(table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(NEU.IMI.CO_lower_ci)))
##
## FALSE TRUE
## 0.2473573 0.7526427
table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(NEU.IMI.CO_upper_ci))
##
## FALSE TRUE
## 342 131
prop.table(table(Doff.by.cow.3$TOTAL.NEU.CO.COW >exp(NEU.IMI.CO_upper_ci)))
##
## FALSE TRUE
## 0.7230444 0.2769556
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_doff_IMI_cow <-PER.NEU.IMI.CO$optimal_cutpoint
table(Doff.by.cow.3$PERCENT.NEU.CO.COW > optimal_per_neu_doff_IMI_cow)
##
## FALSE TRUE
## 249 224
prop.table(table(Doff.by.cow.3$PERCENT.NEU.CO.COW > optimal_per_neu_doff_IMI_cow))
##
## FALSE TRUE
## 0.5264271 0.4735729
# confidence intervals
table(Doff.by.cow.3$PERCENT.NEU.CO.COW > PER.NEU.IMI.CO_lower_ci)
##
## FALSE TRUE
## 60 413
prop.table(table(Doff.by.cow.3$PERCENT.NEU.CO.COW > PER.NEU.IMI.CO_lower_ci))
##
## FALSE TRUE
## 0.1268499 0.8731501
table(Doff.by.cow.3$PERCENT.NEU.CO.COW > PER.NEU.IMI.CO_upper_ci)
##
## FALSE TRUE
## 398 75
prop.table(table(Doff.by.cow.3$PERCENT.NEU.CO.COW >PER.NEU.IMI.CO_upper_ci))
##
## FALSE TRUE
## 0.8414376 0.1585624
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_doff_IMI_cow <-LYM.IMI.CO$optimal_cutpoint
table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(optimal_lym_doff_IMI_cow))
##
## FALSE TRUE
## 223 250
prop.table(table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(optimal_lym_doff_IMI_cow)))
##
## FALSE TRUE
## 0.4714588 0.5285412
# confidence intervals
table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(LYM.IMI.CO_lower_ci))
##
## FALSE TRUE
## 175 298
prop.table(table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(LYM.IMI.CO_lower_ci)))
##
## FALSE TRUE
## 0.3699789 0.6300211
table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(LYM.IMI.CO_upper_ci))
##
## FALSE TRUE
## 365 108
prop.table(table(Doff.by.cow.3$TOTAL.LYM.CO.COW >exp(LYM.IMI.CO_upper_ci)))
##
## FALSE TRUE
## 0.7716702 0.2283298
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_doff_IMI_cow <-PER.LYM.IMI.CO$optimal_cutpoint
table(Doff.by.cow.3$PERCENT.LYM.CO.COW > optimal_per_lym_doff_IMI_cow)
##
## FALSE TRUE
## 197 276
prop.table(table(Doff.by.cow.3$PERCENT.LYM.CO.COW > optimal_per_lym_doff_IMI_cow))
##
## FALSE TRUE
## 0.4164905 0.5835095
# confidence intervals
table(Doff.by.cow.3$PERCENT.LYM.CO.COW > PER.LYM.IMI.CO_lower_ci)
##
## FALSE TRUE
## 20 453
prop.table(table(Doff.by.cow.3$PERCENT.LYM.CO.COW > PER.LYM.IMI.CO_lower_ci))
##
## FALSE TRUE
## 0.0422833 0.9577167
table(Doff.by.cow.3$PERCENT.LYM.CO.COW > PER.LYM.IMI.CO_upper_ci)
##
## FALSE TRUE
## 454 19
prop.table(table(Doff.by.cow.3$PERCENT.LYM.CO.COW >PER.LYM.IMI.CO_upper_ci))
##
## FALSE TRUE
## 0.95983087 0.04016913
# ---- Macrophages ----
# optimal cut-off
optimal_mac_doff_IMI_cow <- MAC.IMI.CO$optimal_cutpoint
table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(optimal_mac_doff_IMI_cow))
##
## FALSE TRUE
## 323 150
prop.table(table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(optimal_mac_doff_IMI_cow)))
##
## FALSE TRUE
## 0.6828753 0.3171247
# confidence intervals
table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(MAC.IMI.CO_lower_ci))
##
## FALSE TRUE
## 101 372
prop.table(table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(MAC.IMI.CO_lower_ci)))
##
## FALSE TRUE
## 0.2135307 0.7864693
table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(MAC.IMI.CO_upper_ci))
##
## FALSE TRUE
## 387 86
prop.table(table(Doff.by.cow.3$TOTAL.MAC.CO.COW >exp(MAC.IMI.CO_upper_ci)))
##
## FALSE TRUE
## 0.8181818 0.1818182
# Percent MAC
# optimal cut-off
optimal_per_mac_doff_IMI_cow <- PER.MAC.IMI.CO$optimal_cutpoint
table(Doff.by.cow.3$PERCENT.MAC.CO.COW > optimal_per_mac_doff_IMI_cow)
##
## FALSE TRUE
## 371 102
prop.table(table(Doff.by.cow.3$PERCENT.MAC.CO.COW > optimal_per_mac_doff_IMI_cow))
##
## FALSE TRUE
## 0.7843552 0.2156448
# confidence intervals
table(Doff.by.cow.3$PERCENT.MAC.CO.COW > PER.MAC.IMI.CO_lower_ci)
##
## FALSE TRUE
## 100 373
prop.table(table(Doff.by.cow.3$PERCENT.MAC.CO.COW > PER.MAC.IMI.CO_lower_ci))
##
## FALSE TRUE
## 0.2114165 0.7885835
table(Doff.by.cow.3$PERCENT.MAC.CO.COW > PER.MAC.IMI.CO_upper_ci)
##
## FALSE TRUE
## 443 30
prop.table(table(Doff.by.cow.3$PERCENT.MAC.CO.COW >PER.MAC.IMI.CO_upper_ci))
##
## FALSE TRUE
## 0.93657505 0.06342495
# Set a seed for reproducibility
set.seed(123)
# Delaval SCM (SCC>200.000) reference
# n NEU SCM COW
NEU.SCM <- cutpointr(Doff.by.cow.3, log.TOTAL.NEU.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.NEU.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9652 472 142 330
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 4.2767 1.8346 0.9068 0.9437 0.8909 0.7882 0.9735
## tp fn fp tn
## 134 8 36 294
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.386294 2.302585 3.135494 3.850148 4.032830 4.738382 6.408518
## 0 1.386294 2.197225 2.847503 3.433987 3.413786 3.951244 4.634729
## 1 3.135494 4.071254 4.738382 5.249621 5.471454 5.968668 7.408120
## Max. SD NAs
## 8.674026 1.2864326 0
## 7.826044 0.7800807 0
## 8.674026 1.0616036 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 4.28 4.28 4.28 4.28 4.30 4.30 4.43 4.74 0.06 0
## AUC_b 0.94 0.95 0.96 0.97 0.97 0.97 0.98 0.99 0.01 0
## AUC_oob 0.92 0.95 0.96 0.97 0.96 0.97 0.98 0.99 0.01 0
## sum_sens_spec_b 1.74 1.79 1.82 1.84 1.84 1.85 1.88 1.92 0.03 0
## sum_sens_spec_oob 1.63 1.75 1.79 1.82 1.82 1.84 1.88 1.94 0.04 0
## acc_b 0.86 0.89 0.90 0.91 0.91 0.92 0.93 0.95 0.01 0
## acc_oob 0.84 0.87 0.89 0.90 0.90 0.91 0.93 0.96 0.02 0
## sensitivity_b 0.80 0.90 0.93 0.94 0.94 0.96 0.97 0.99 0.02 0
## sensitivity_oob 0.66 0.85 0.90 0.93 0.92 0.95 0.98 1.00 0.04 0
## specificity_b 0.84 0.87 0.88 0.90 0.90 0.91 0.93 0.97 0.02 0
## specificity_oob 0.82 0.85 0.88 0.89 0.89 0.91 0.93 0.97 0.02 0
## cohens_kappa_b 0.69 0.75 0.77 0.79 0.79 0.81 0.84 0.89 0.03 0
## cohens_kappa_oob 0.62 0.71 0.75 0.78 0.78 0.80 0.84 0.92 0.04 0
## ppv_b 0.67 0.74 0.77 0.79 0.79 0.82 0.85 0.91 0.03 0
## ppv_oob 0.65 0.72 0.76 0.79 0.79 0.81 0.86 0.93 0.04 0
## npv_b 0.91 0.95 0.97 0.97 0.97 0.98 0.99 1.00 0.01 0
## npv_oob 0.85 0.93 0.95 0.97 0.96 0.98 0.99 1.00 0.02 0
# ROC plot
plot(NEU.SCM)
# Youden index plot
plot_metric(NEU.SCM)
# %NEU SCM COW
PER.NEU.SCM <- cutpointr(Doff.by.cow.3, PERCENT.NEU.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.SCM)
## Method: maximize_metric
## Predictor: PERCENT.NEU.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5615 472 142 330
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 60.7 1.2045 0.6907 0.3803 0.8242 0.4821 0.7556 54
## fn fp tn
## 88 58 272
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 15.69 29.2785 41.6925 51.14 50.71117 59.7675 70.3470 122.00 12.76777
## 0 15.69 30.7200 41.8025 50.00 49.87433 57.2675 68.6085 76.74 11.21753
## 1 19.90 27.4670 41.5350 54.27 52.65592 64.0825 73.3420 122.00 15.66793
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 49.33 54.20 56.32 59.90 58.78 60.70 61.34 69.68 2.45
## AUC_b 0.46 0.51 0.54 0.56 0.56 0.58 0.61 0.66 0.03
## AUC_oob 0.36 0.49 0.53 0.56 0.56 0.59 0.63 0.71 0.04
## sum_sens_spec_b 1.06 1.14 1.18 1.21 1.22 1.25 1.29 1.36 0.05
## sum_sens_spec_oob 0.90 1.06 1.13 1.17 1.17 1.21 1.27 1.40 0.06
## acc_b 0.57 0.63 0.66 0.68 0.68 0.70 0.72 0.76 0.03
## acc_oob 0.43 0.59 0.63 0.66 0.66 0.69 0.72 0.77 0.04
## sensitivity_b 0.14 0.33 0.38 0.42 0.43 0.48 0.54 0.68 0.07
## sensitivity_oob 0.09 0.27 0.34 0.39 0.39 0.45 0.52 0.66 0.08
## specificity_b 0.51 0.69 0.74 0.80 0.79 0.83 0.86 0.96 0.06
## specificity_oob 0.40 0.66 0.73 0.79 0.77 0.83 0.86 0.96 0.07
## cohens_kappa_b 0.06 0.15 0.19 0.22 0.22 0.25 0.30 0.36 0.05
## cohens_kappa_oob -0.08 0.06 0.13 0.17 0.17 0.22 0.28 0.39 0.07
## ppv_b 0.33 0.39 0.43 0.47 0.47 0.50 0.56 0.65 0.05
## ppv_oob 0.18 0.33 0.39 0.43 0.43 0.48 0.55 0.69 0.07
## npv_b 0.68 0.72 0.75 0.76 0.76 0.78 0.80 0.84 0.02
## npv_oob 0.63 0.70 0.73 0.75 0.75 0.77 0.80 0.86 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.SCM)
# Youden index plot
plot_metric(PER.NEU.SCM)
# Lym
LYM.SCM <- cutpointr(Doff.by.cow.3, log.TOTAL.LYM.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.LYM.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9545 472 142 330
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.3322 1.7904 0.8983 0.8873 0.903 0.7975 0.949 126
## fn fp tn
## 16 32 298
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.098612 2.079442 2.833213 2.929250 3.663562 4.904507
## 0 0.000000 1.098612 1.945910 2.397895 2.381204 2.944439 3.555348
## 1 1.609438 3.044522 3.663562 4.077537 4.202878 4.632290 5.847005
## Max. SD NAs
## 7.082549 1.1672845 0
## 5.283204 0.7833538 0
## 7.082549 0.8849212 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.94 3.18 3.33 3.34 3.36 3.40 3.56 3.64 0.11 0
## AUC_b 0.91 0.94 0.95 0.95 0.95 0.96 0.97 0.98 0.01 0
## AUC_oob 0.90 0.93 0.95 0.95 0.95 0.96 0.98 0.99 0.01 0
## sum_sens_spec_b 1.69 1.75 1.78 1.80 1.80 1.82 1.85 1.89 0.03 0
## sum_sens_spec_oob 1.54 1.69 1.73 1.77 1.76 1.79 1.84 1.89 0.05 0
## acc_b 0.83 0.87 0.89 0.90 0.90 0.92 0.93 0.95 0.02 0
## acc_oob 0.77 0.85 0.88 0.89 0.89 0.90 0.92 0.95 0.02 0
## sensitivity_b 0.77 0.83 0.87 0.89 0.89 0.91 0.94 0.99 0.03 0
## sensitivity_oob 0.61 0.77 0.83 0.87 0.86 0.90 0.94 1.00 0.05 0
## specificity_b 0.78 0.85 0.89 0.91 0.91 0.93 0.95 0.98 0.03 0
## specificity_oob 0.70 0.82 0.88 0.90 0.90 0.93 0.95 0.98 0.04 0
## cohens_kappa_b 0.62 0.71 0.75 0.78 0.78 0.80 0.83 0.88 0.04 0
## cohens_kappa_oob 0.52 0.66 0.71 0.75 0.74 0.77 0.82 0.89 0.05 0
## ppv_b 0.61 0.72 0.78 0.81 0.81 0.84 0.89 0.94 0.05 0
## ppv_oob 0.53 0.68 0.76 0.80 0.79 0.83 0.89 0.96 0.06 0
## npv_b 0.90 0.93 0.94 0.95 0.95 0.96 0.97 1.00 0.01 0
## npv_oob 0.85 0.90 0.93 0.94 0.94 0.95 0.97 1.00 0.02 0
# ROC plot
plot(LYM.SCM)
# Youden index plot
plot_metric(LYM.SCM)
# %LYM SCM COW
PER.LYM.SCM <- cutpointr(Doff.by.cow.3, PERCENT.LYM.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.SCM)
## Method: maximize_metric
## Predictor: PERCENT.LYM.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.6581 472 330 142
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 18.1 1.2454 0.5678 0.4848 0.7606 0.8247 0.3885
## tp fn fp tn
## 160 170 34 108
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 3.54 8.0955 12.7500 16.925 17.72085 21.2025 30.4885 69.0 7.392967 0
## 0 4.30 9.2030 13.7450 17.860 18.73639 22.9425 31.2500 54.5 7.233222 0
## 1 3.54 7.2440 11.0325 14.260 15.36077 18.0500 25.4925 69.0 7.243765 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 10.09 13.01 14.04 17.19 16.59 18.10 19.13 24.40 2.13
## AUC_b 0.56 0.61 0.64 0.66 0.66 0.68 0.70 0.74 0.03
## AUC_oob 0.51 0.60 0.63 0.66 0.66 0.68 0.72 0.79 0.04
## sum_sens_spec_b 1.12 1.20 1.24 1.27 1.27 1.30 1.34 1.41 0.04
## sum_sens_spec_oob 1.00 1.09 1.15 1.19 1.19 1.23 1.29 1.42 0.06
## acc_b 0.42 0.54 0.57 0.61 0.62 0.67 0.71 0.76 0.06
## acc_oob 0.38 0.50 0.54 0.58 0.58 0.63 0.68 0.74 0.06
## sensitivity_b 0.18 0.43 0.49 0.56 0.59 0.73 0.81 0.95 0.13
## sensitivity_oob 0.19 0.38 0.46 0.53 0.57 0.70 0.80 0.94 0.14
## specificity_b 0.23 0.45 0.55 0.72 0.68 0.79 0.84 0.96 0.13
## specificity_oob 0.12 0.37 0.48 0.67 0.62 0.75 0.82 0.96 0.15
## cohens_kappa_b 0.08 0.16 0.20 0.23 0.23 0.26 0.31 0.41 0.05
## cohens_kappa_oob 0.00 0.07 0.12 0.16 0.16 0.20 0.25 0.37 0.05
## ppv_b 0.72 0.76 0.79 0.82 0.82 0.84 0.88 0.95 0.04
## ppv_oob 0.62 0.71 0.75 0.78 0.78 0.81 0.86 0.94 0.04
## npv_b 0.31 0.36 0.39 0.42 0.43 0.46 0.52 0.67 0.05
## npv_oob 0.23 0.31 0.35 0.39 0.39 0.42 0.48 0.60 0.05
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.LYM.SCM)
# Youden index plot
plot_metric(PER.LYM.SCM)
# MAC SCM COW
MAC.SCM <- cutpointr(Doff.by.cow.3, log.TOTAL.MAC.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.MAC.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9457 472 142 330
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.1744 1.7583 0.8983 0.831 0.9273 0.831 0.9273 118
## fn fp tn
## 24 24 306
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.609438 2.564949 3.384247 3.486201 4.412744 5.738424
## 0 0.000000 1.098612 2.197225 2.944439 2.868476 3.526361 4.276666
## 1 2.772589 3.232757 4.412744 4.927254 4.921760 5.424950 6.410421
## Max. SD NAs
## 7.289611 1.3335800 0
## 6.601230 0.9724210 0
## 7.289611 0.8751049 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.53 3.91 4.01 4.17 4.15 4.32 4.33 4.60 0.15 0
## AUC_b 0.90 0.93 0.94 0.95 0.95 0.95 0.96 0.97 0.01 0
## AUC_oob 0.89 0.92 0.94 0.95 0.95 0.96 0.97 0.99 0.01 0
## sum_sens_spec_b 1.65 1.72 1.75 1.77 1.77 1.79 1.82 1.88 0.03 0
## sum_sens_spec_oob 1.53 1.66 1.70 1.73 1.73 1.76 1.81 1.87 0.05 0
## acc_b 0.83 0.87 0.89 0.90 0.90 0.91 0.93 0.95 0.02 0
## acc_oob 0.75 0.84 0.87 0.89 0.88 0.90 0.92 0.95 0.02 0
## sensitivity_b 0.71 0.78 0.82 0.85 0.85 0.88 0.91 0.96 0.04 0
## sensitivity_oob 0.58 0.73 0.78 0.82 0.82 0.86 0.91 0.98 0.06 0
## specificity_b 0.80 0.86 0.90 0.93 0.92 0.95 0.96 0.99 0.03 0
## specificity_oob 0.69 0.84 0.88 0.92 0.91 0.94 0.97 1.00 0.04 0
## cohens_kappa_b 0.61 0.70 0.74 0.77 0.76 0.79 0.82 0.87 0.04 0
## cohens_kappa_oob 0.48 0.64 0.69 0.73 0.73 0.76 0.81 0.88 0.05 0
## ppv_b 0.61 0.73 0.78 0.83 0.83 0.87 0.91 0.96 0.06 0
## ppv_oob 0.52 0.68 0.75 0.81 0.81 0.86 0.92 1.00 0.07 0
## npv_b 0.88 0.91 0.92 0.93 0.93 0.95 0.96 0.98 0.02 0
## npv_oob 0.82 0.88 0.91 0.92 0.92 0.94 0.96 0.99 0.02 0
# ROC plot
plot(MAC.SCM)
# Youden index plot
plot_metric(MAC.SCM)
# %MAC SCM COW
PER.MAC.SCM <- cutpointr(Doff.by.cow.3, PERCENT.MAC.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.SCM)
## Method: maximize_metric
## Predictor: PERCENT.MAC.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.492 472 330 142
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 17.53 1.0819 0.6695 0.8636 0.2183 0.7197 0.4079
## tp fn fp tn
## 285 45 111 31
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 3.41 12.3650 20.5825 29.845 31.87684 41.45 58.0275 74.51 14.27063
## 0 3.41 12.3350 21.1925 30.225 31.38961 40.72 52.9780 74.51 13.26877
## 1 5.85 13.2085 19.4250 29.545 33.00915 45.96 62.1030 72.70 16.35931
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 9.38 17.53 17.53 20.59 Inf 26.85 32.96 Inf NaN 0
## AUC_b 0.39 0.44 0.47 0.49 0.49 0.51 0.54 0.60 0.03 0
## AUC_oob 0.36 0.43 0.46 0.49 0.49 0.52 0.56 0.65 0.04 0
## sum_sens_spec_b 1.00 1.04 1.07 1.10 1.10 1.13 1.16 1.24 0.04 0
## sum_sens_spec_oob 0.78 0.92 0.99 1.03 1.03 1.07 1.13 1.26 0.06 0
## acc_b 0.28 0.51 0.58 0.65 0.63 0.67 0.70 0.75 0.06 0
## acc_oob 0.24 0.46 0.54 0.61 0.60 0.66 0.70 0.74 0.08 0
## sensitivity_b 0.00 0.46 0.63 0.80 0.74 0.86 0.89 0.98 0.15 0
## sensitivity_oob 0.00 0.42 0.59 0.77 0.72 0.85 0.88 0.97 0.16 0
## specificity_b 0.05 0.19 0.23 0.31 0.36 0.47 0.64 1.00 0.15 0
## specificity_oob 0.00 0.15 0.21 0.27 0.31 0.40 0.57 1.00 0.14 0
## cohens_kappa_b 0.00 0.04 0.07 0.10 0.10 0.13 0.17 0.24 0.04 0
## cohens_kappa_oob -0.20 -0.07 -0.01 0.03 0.03 0.08 0.14 0.27 0.07 0
## ppv_b 0.66 0.69 0.71 0.73 0.73 0.75 0.77 1.00 0.03 2
## ppv_oob 0.25 0.65 0.69 0.71 0.71 0.73 0.76 0.81 0.04 7
## npv_b 0.27 0.31 0.35 0.38 0.39 0.42 0.49 0.59 0.05 0
## npv_oob 0.00 0.24 0.29 0.33 0.34 0.38 0.47 0.67 0.07 0
# ROC plot
plot(PER.MAC.SCM)
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(PER.MAC.SCM)
# Summary of results when using SCM as reference
print(c("Optimal n NEU:", exp(NEU.SCM$optimal_cutpoint), NEU.SCM$sensitivity, NEU.SCM$specificity, NEU.SCM$ppv, NEU.SCM$npv, NEU.SCM$AUC))
## sensitivity specificity
## "Optimal n NEU:" "72" "0.943661971830986" "0.890909090909091"
##
## "0.788235294117647" "0.973509933774834" "0.965215535638071"
print(c("Optimal %NEU:", PER.NEU.SCM$optimal_cutpoint, PER.NEU.SCM$sensitivity, PER.NEU.SCM$specificity, PER.NEU.SCM$ppv, PER.NEU.SCM$npv, PER.NEU.SCM$AUC))
## sensitivity specificity
## "Optimal %NEU:" "60.7" "0.380281690140845" "0.824242424242424"
##
## "0.482142857142857" "0.755555555555556" "0.561491677336748"
print(c("Optimal n LYM:", exp(LYM.SCM$optimal_cutpoint), LYM.SCM$sensitivity, LYM.SCM$specificity, LYM.SCM$ppv, LYM.SCM$npv, LYM.SCM$AUC))
## sensitivity specificity
## "Optimal n LYM:" "28" "0.887323943661972" "0.903030303030303"
##
## "0.79746835443038" "0.949044585987261" "0.954492104139991"
print(c("Optimal %LYM:", PER.LYM.SCM$optimal_cutpoint, PER.LYM.SCM$sensitivity, PER.LYM.SCM$specificity, PER.LYM.SCM$ppv, PER.LYM.SCM$npv, PER.LYM.SCM$AUC))
## sensitivity specificity
## "Optimal %LYM:" "18.1" "0.484848484848485" "0.76056338028169"
##
## "0.824742268041237" "0.388489208633094" "0.658087921468203"
print(c("Optimal n MAC:", exp(MAC.SCM$optimal_cutpoint), MAC.SCM$sensitivity, MAC.SCM$specificity, MAC.SCM$ppv, MAC.SCM$npv, MAC.SCM$AUC))
## sensitivity specificity
## "Optimal n MAC:" "65" "0.830985915492958" "0.927272727272727"
##
## "0.830985915492958" "0.927272727272727" "0.945657276995305"
print(c("Optimal %MAC:", PER.MAC.SCM$optimal_cutpoint, PER.MAC.SCM$sensitivity, PER.MAC.SCM$specificity, PER.MAC.SCM$ppv, PER.MAC.SCM$npv, PER.MAC.SCM$AUC))
## sensitivity specificity
## "Optimal %MAC:" "17.53" "0.863636363636364" "0.21830985915493"
##
## "0.71969696969697" "0.407894736842105" "0.491954758856167"
# CI using bp
# Number neu
NEU.SCM_optimal_cutpoint <- boot_ci(NEU.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.SCM_lower_ci <- subset(NEU.SCM_optimal_cutpoint, NEU.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.SCM_lower_ci)
## [1] 72
NEU.SCM_upper_ci <- subset(NEU.SCM_optimal_cutpoint, NEU.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.SCM_upper_ci)
## [1] 86
boot_ci(NEU.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.892
## 2 0.975 0.978
boot_ci(NEU.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.860
## 2 0.975 0.931
boot_ci(NEU.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.728
## 2 0.975 0.862
boot_ci(NEU.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.951
## 2 0.975 0.990
boot_ci(NEU.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.949
## 2 0.975 0.980
# Percent neu
PER.NEU.SCM_optimal_cutpoint <- boot_ci(PER.NEU.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 54.1
## 2 0.975 62.4
PER.NEU.SCM_lower_ci <- subset(PER.NEU.SCM_optimal_cutpoint, PER.NEU.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.SCM_upper_ci <- subset(PER.NEU.SCM_optimal_cutpoint, PER.NEU.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.303
## 2 0.975 0.560
boot_ci(PER.NEU.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.665
## 2 0.975 0.872
boot_ci(PER.NEU.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.374
## 2 0.975 0.575
boot_ci(PER.NEU.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.716
## 2 0.975 0.807
boot_ci(PER.NEU.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.503
## 2 0.975 0.623
# Number lym
LYM.SCM_optimal_cutpoint <- boot_ci(LYM.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.SCM_lower_ci <- subset(LYM.SCM_optimal_cutpoint, LYM.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.SCM_lower_ci)
## [1] 21
LYM.SCM_upper_ci <- subset(LYM.SCM_optimal_cutpoint, LYM.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.SCM_upper_ci)
## [1] 35
boot_ci(LYM.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.824
## 2 0.975 0.953
boot_ci(LYM.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.828
## 2 0.975 0.958
boot_ci(LYM.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.696
## 2 0.975 0.897
boot_ci(LYM.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.922
## 2 0.975 0.978
boot_ci(LYM.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.932
## 2 0.975 0.973
# Percent lym
PER.LYM.SCM_optimal_cutpoint <- boot_ci(PER.LYM.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 13.0
## 2 0.975 19.2
PER.LYM.SCM_lower_ci <- subset(PER.LYM.SCM_optimal_cutpoint, PER.LYM.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.SCM_upper_ci <- subset(PER.LYM.SCM_optimal_cutpoint, PER.LYM.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.404
## 2 0.975 0.821
boot_ci(PER.LYM.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.427
## 2 0.975 0.861
boot_ci(PER.LYM.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.75
## 2 0.975 0.888
boot_ci(PER.LYM.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.347
## 2 0.975 0.543
boot_ci(PER.LYM.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.604
## 2 0.975 0.708
# Number mac
MAC.SCM_optimal_cutpoint <- boot_ci(MAC.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.SCM_lower_ci <- subset(MAC.SCM_optimal_cutpoint, MAC.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.SCM_lower_ci)
## [1] 45
MAC.SCM_upper_ci <- subset(MAC.SCM_optimal_cutpoint, MAC.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.SCM_upper_ci)
## [1] 78
boot_ci(MAC.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.775
## 2 0.975 0.924
boot_ci(MAC.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.853
## 2 0.975 0.970
boot_ci(MAC.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.717
## 2 0.975 0.922
boot_ci(MAC.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.903
## 2 0.975 0.965
boot_ci(MAC.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.924
## 2 0.975 0.965
# Percent mac
PER.MAC.SCM_optimal_cutpoint <- boot_ci(PER.MAC.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 17.5
## 2 0.975 33.3
PER.MAC.SCM_lower_ci <- subset(PER.MAC.SCM_optimal_cutpoint, PER.MAC.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.SCM_upper_ci <- subset(PER.MAC.SCM_optimal_cutpoint, PER.MAC.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.440
## 2 0.975 0.897
boot_ci(PER.MAC.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.172
## 2 0.975 0.660
boot_ci(PER.MAC.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.682
## 2 0.975 0.781
boot_ci(PER.MAC.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.302
## 2 0.975 0.506
boot_ci(PER.MAC.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.435
## 2 0.975 0.552
# Prevalence
# True prevalence
table(Doff.by.cow.3$delaval.SCM.CO.COW)
##
## 0 1
## 341 145
prop.table(table(Doff.by.cow.3$delaval.SCM.CO.COW))
##
## 0 1
## 0.7016461 0.2983539
#Apparent prevalence
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_doff_SCM_cow <- NEU.SCM$optimal_cutpoint
table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(optimal_neu_doff_SCM_cow))
##
## FALSE TRUE
## 304 169
prop.table(table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(optimal_neu_doff_SCM_cow)))
##
## FALSE TRUE
## 0.6427061 0.3572939
# confidence intervals
table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(NEU.SCM_lower_ci))
##
## FALSE TRUE
## 304 169
prop.table(table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(NEU.SCM_lower_ci)))
##
## FALSE TRUE
## 0.6427061 0.3572939
table(Doff.by.cow.3$TOTAL.NEU.CO.COW > exp(NEU.SCM_upper_ci))
##
## FALSE TRUE
## 319 154
prop.table(table(Doff.by.cow.3$TOTAL.NEU.CO.COW >exp(NEU.SCM_upper_ci)))
##
## FALSE TRUE
## 0.6744186 0.3255814
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_doff_SCM_cow <-PER.NEU.SCM$optimal_cutpoint
table(Doff.by.cow.3$PERCENT.NEU.CO.COW > optimal_per_neu_doff_SCM_cow)
##
## FALSE TRUE
## 362 111
prop.table(table(Doff.by.cow.3$PERCENT.NEU.CO.COW > optimal_per_neu_doff_SCM_cow))
##
## FALSE TRUE
## 0.7653277 0.2346723
# confidence intervals
table(Doff.by.cow.3$PERCENT.NEU.CO.COW > PER.NEU.SCM_lower_ci)
##
## FALSE TRUE
## 287 186
prop.table(table(Doff.by.cow.3$PERCENT.NEU.CO.COW > PER.NEU.SCM_lower_ci))
##
## FALSE TRUE
## 0.6067653 0.3932347
table(Doff.by.cow.3$PERCENT.NEU.CO.COW > PER.NEU.SCM_upper_ci)
##
## FALSE TRUE
## 380 93
prop.table(table(Doff.by.cow.3$PERCENT.NEU.CO.COW >PER.NEU.SCM_upper_ci))
##
## FALSE TRUE
## 0.8033827 0.1966173
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_doff_SCM_cow <-LYM.SCM$optimal_cutpoint
table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(optimal_lym_doff_SCM_cow))
##
## FALSE TRUE
## 315 158
prop.table(table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(optimal_lym_doff_SCM_cow)))
##
## FALSE TRUE
## 0.6659619 0.3340381
# confidence intervals
table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(LYM.SCM_lower_ci))
##
## FALSE TRUE
## 278 195
prop.table(table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(LYM.SCM_lower_ci)))
##
## FALSE TRUE
## 0.5877378 0.4122622
table(Doff.by.cow.3$TOTAL.LYM.CO.COW > exp(LYM.SCM_upper_ci))
##
## FALSE TRUE
## 338 135
prop.table(table(Doff.by.cow.3$TOTAL.LYM.CO.COW >exp(LYM.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7145877 0.2854123
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_doff_SCM_cow <-PER.LYM.SCM$optimal_cutpoint
table(Doff.by.cow.3$PERCENT.LYM.CO.COW > optimal_per_lym_doff_SCM_cow)
##
## FALSE TRUE
## 281 192
prop.table(table(Doff.by.cow.3$PERCENT.LYM.CO.COW > optimal_per_lym_doff_SCM_cow))
##
## FALSE TRUE
## 0.5940803 0.4059197
# confidence intervals
table(Doff.by.cow.3$PERCENT.LYM.CO.COW > PER.LYM.SCM_lower_ci)
##
## FALSE TRUE
## 128 345
prop.table(table(Doff.by.cow.3$PERCENT.LYM.CO.COW > PER.LYM.SCM_lower_ci))
##
## FALSE TRUE
## 0.2706131 0.7293869
table(Doff.by.cow.3$PERCENT.LYM.CO.COW > PER.LYM.SCM_upper_ci)
##
## FALSE TRUE
## 310 163
prop.table(table(Doff.by.cow.3$PERCENT.LYM.CO.COW >PER.LYM.SCM_upper_ci))
##
## FALSE TRUE
## 0.6553911 0.3446089
# ---- Macrophages ----
# optimal cut-off
optimal_mac_doff_SCM_cow <- MAC.SCM$optimal_cutpoint
table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(optimal_mac_doff_SCM_cow))
##
## FALSE TRUE
## 331 142
prop.table(table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(optimal_mac_doff_SCM_cow)))
##
## FALSE TRUE
## 0.6997886 0.3002114
# confidence intervals
table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(MAC.SCM_lower_ci))
##
## FALSE TRUE
## 293 180
prop.table(table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(MAC.SCM_lower_ci)))
##
## FALSE TRUE
## 0.6194503 0.3805497
table(Doff.by.cow.3$TOTAL.MAC.CO.COW > exp(MAC.SCM_upper_ci))
##
## FALSE TRUE
## 350 123
prop.table(table(Doff.by.cow.3$TOTAL.MAC.CO.COW >exp(MAC.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7399577 0.2600423
# Percent MAC
# optimal cut-off
optimal_per_mac_doff_SCM_cow <- PER.MAC.SCM$optimal_cutpoint
table(Doff.by.cow.3$PERCENT.MAC.CO.COW > optimal_per_mac_doff_SCM_cow)
##
## FALSE TRUE
## 77 396
prop.table(table(Doff.by.cow.3$PERCENT.MAC.CO.COW > optimal_per_mac_doff_SCM_cow))
##
## FALSE TRUE
## 0.1627907 0.8372093
# confidence intervals
table(Doff.by.cow.3$PERCENT.MAC.CO.COW > PER.MAC.SCM_lower_ci)
##
## FALSE TRUE
## 77 396
prop.table(table(Doff.by.cow.3$PERCENT.MAC.CO.COW > PER.MAC.SCM_lower_ci))
##
## FALSE TRUE
## 0.1627907 0.8372093
table(Doff.by.cow.3$PERCENT.MAC.CO.COW > PER.MAC.SCM_upper_ci)
##
## FALSE TRUE
## 274 199
prop.table(table(Doff.by.cow.3$PERCENT.MAC.CO.COW >PER.MAC.SCM_upper_ci))
##
## FALSE TRUE
## 0.5792812 0.4207188
# ------ Quarter level -------
set.seed(123)
# SCC IMI quarter
SCC.IMI <- cutpointr(Doff.by.quarter.2, log.SCC, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(SCC.IMI)
## Method: maximize_metric
## Predictor: log.SCC
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5876 1780 749 1031
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.5539 1.1494 0.5888 0.486 0.6634 0.512 0.6399 364
## fn fp tn
## 385 347 684
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.098612 2.564949 3.576476 4.290459 4.355470 5.057833 6.504438
## 0 1.098612 2.484907 3.465736 4.127134 4.191412 4.828314 5.978883
## 1 1.098612 2.639057 3.713572 4.499810 4.581296 5.365976 7.021595
## Max. SD NAs
## 8.589514 1.196636 0
## 8.239593 1.077550 0
## 8.589514 1.310959 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 4.11 4.38 4.50 4.63 4.74 5.02 5.16 5.41 0.29 0
## AUC_b 0.54 0.56 0.58 0.59 0.59 0.60 0.61 0.63 0.01 0
## AUC_oob 0.53 0.56 0.58 0.59 0.59 0.60 0.62 0.66 0.02 0
## sum_sens_spec_b 1.10 1.12 1.14 1.16 1.16 1.17 1.19 1.23 0.02 0
## sum_sens_spec_oob 1.03 1.08 1.11 1.13 1.13 1.15 1.17 1.23 0.03 0
## acc_b 0.54 0.58 0.59 0.60 0.60 0.61 0.63 0.65 0.02 0
## acc_oob 0.52 0.55 0.57 0.59 0.59 0.60 0.62 0.65 0.02 0
## sensitivity_b 0.23 0.30 0.36 0.46 0.44 0.52 0.56 0.64 0.09 0
## sensitivity_oob 0.20 0.28 0.34 0.44 0.42 0.50 0.55 0.64 0.09 0
## specificity_b 0.48 0.60 0.65 0.69 0.72 0.80 0.84 0.90 0.08 0
## specificity_oob 0.45 0.58 0.63 0.68 0.70 0.79 0.84 0.89 0.09 0
## cohens_kappa_b 0.10 0.13 0.15 0.16 0.16 0.18 0.20 0.24 0.02 0
## cohens_kappa_oob 0.03 0.08 0.11 0.13 0.13 0.15 0.18 0.23 0.03 0
## ppv_b 0.45 0.49 0.51 0.53 0.54 0.56 0.60 0.68 0.03 0
## ppv_oob 0.41 0.46 0.49 0.51 0.52 0.54 0.59 0.67 0.04 0
## npv_b 0.58 0.61 0.63 0.64 0.64 0.65 0.67 0.69 0.02 0
## npv_oob 0.57 0.60 0.62 0.63 0.63 0.64 0.66 0.70 0.02 0
# ROC plot
plot(SCC.IMI)
# Youden index plot
plot_metric(SCC.IMI)
# NEU IMI COW
NEU.IMI <- cutpointr(Doff.by.quarter.2, log.Neu, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.IMI)
## Method: maximize_metric
## Predictor: log.Neu
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5934 1771 745 1026
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.0604 1.1598 0.6076 0.4054 0.7544 0.5451 0.636 302
## fn fp tn
## 443 252 774
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.6931472 2.079442 2.772589 3.496508 3.678804 4.290459 6.008786
## 0 0.6931472 1.945910 2.708050 3.332205 3.487747 4.043051 5.394746
## 1 0.6931472 2.079442 2.944439 3.737670 3.941923 4.663439 6.859057
## Max. SD NAs
## 9.342946 1.266397 0
## 9.342946 1.100800 0
## 9.327056 1.423484 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.18 3.69 3.87 4.06 4.01 4.16 4.22 4.83 0.19 0
## AUC_b 0.55 0.57 0.58 0.59 0.59 0.60 0.62 0.64 0.01 0
## AUC_oob 0.52 0.56 0.58 0.59 0.59 0.61 0.62 0.65 0.02 0
## sum_sens_spec_b 1.10 1.13 1.15 1.17 1.17 1.18 1.20 1.24 0.02 0
## sum_sens_spec_oob 1.01 1.09 1.12 1.14 1.14 1.16 1.19 1.24 0.03 0
## acc_b 0.55 0.58 0.60 0.61 0.61 0.62 0.63 0.65 0.01 0
## acc_oob 0.49 0.56 0.58 0.60 0.60 0.61 0.63 0.66 0.02 0
## sensitivity_b 0.24 0.35 0.39 0.41 0.43 0.47 0.54 0.74 0.06 0
## sensitivity_oob 0.16 0.34 0.37 0.40 0.42 0.45 0.52 0.67 0.06 0
## specificity_b 0.43 0.63 0.70 0.76 0.74 0.78 0.81 0.91 0.06 0
## specificity_oob 0.41 0.61 0.68 0.75 0.73 0.77 0.80 0.89 0.07 0
## cohens_kappa_b 0.10 0.14 0.16 0.17 0.17 0.19 0.21 0.24 0.02 0
## cohens_kappa_oob 0.01 0.09 0.12 0.15 0.15 0.17 0.20 0.26 0.03 0
## ppv_b 0.46 0.50 0.53 0.55 0.55 0.57 0.59 0.67 0.03 0
## ppv_oob 0.42 0.47 0.50 0.53 0.53 0.55 0.58 0.65 0.03 0
## npv_b 0.60 0.62 0.63 0.64 0.64 0.65 0.67 0.70 0.02 0
## npv_oob 0.57 0.60 0.62 0.63 0.63 0.64 0.66 0.69 0.02 0
# ROC plot
plot(NEU.IMI)
# Youden index plot
plot_metric(NEU.IMI)
# %NEU IMI quarter
PER.NEU.IMI <- cutpointr(Doff.by.quarter.2, PERCENT01_N, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.IMI)
## Method: maximize_metric
## Predictor: PERCENT01_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5159 1771 745 1026
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 61.02 1.0497 0.5726 0.2242 0.8255 0.4827 0.5944
## tp fn fp tn
## 167 578 179 847
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 13.06 29.510 41.9600 50.00 50.30749 58.925 69.6450 85.71 12.11916
## 0 13.06 29.365 42.1025 50.00 50.04235 58.300 69.2225 85.71 11.88813
## 1 16.67 30.006 41.7900 50.74 50.67264 59.720 70.3340 84.62 12.42908
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 25.86 48.50 51.52 57.30 56.31 60.70 61.30 71.72 5.29
## AUC_b 0.47 0.49 0.51 0.52 0.52 0.53 0.54 0.57 0.01
## AUC_oob 0.45 0.49 0.50 0.52 0.52 0.53 0.55 0.58 0.02
## sum_sens_spec_b 1.00 1.03 1.05 1.06 1.06 1.07 1.10 1.14 0.02
## sum_sens_spec_oob 0.92 0.97 1.00 1.02 1.02 1.04 1.07 1.12 0.03
## acc_b 0.43 0.51 0.54 0.56 0.56 0.57 0.59 0.61 0.02
## acc_oob 0.39 0.48 0.52 0.54 0.54 0.56 0.58 0.61 0.03
## sensitivity_b 0.05 0.21 0.24 0.33 0.37 0.49 0.61 0.99 0.15
## sensitivity_oob 0.02 0.18 0.23 0.31 0.34 0.45 0.58 0.98 0.14
## specificity_b 0.02 0.46 0.57 0.73 0.70 0.82 0.84 0.98 0.15
## specificity_oob 0.01 0.43 0.54 0.72 0.68 0.81 0.84 0.97 0.15
## cohens_kappa_b 0.00 0.03 0.05 0.06 0.06 0.08 0.10 0.15 0.02
## cohens_kappa_oob -0.08 -0.03 0.00 0.03 0.02 0.04 0.07 0.12 0.03
## ppv_b 0.40 0.43 0.45 0.47 0.47 0.49 0.52 0.66 0.03
## ppv_oob 0.30 0.39 0.42 0.44 0.44 0.46 0.50 0.57 0.03
## npv_b 0.56 0.58 0.59 0.60 0.60 0.61 0.63 0.77 0.02
## npv_oob 0.42 0.55 0.57 0.59 0.59 0.60 0.62 0.67 0.02
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.IMI)
# Youden index plot
plot_metric(PER.NEU.IMI)
# SCC IMI quarter
LYM.IMI <- cutpointr(Doff.by.quarter.2, log.Lym, IMI, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.IMI)
## Method: maximize_metric
## Predictor: log.Lym
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5957 1771 745 1026
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 2.8904 1.1722 0.6014 0.4899 0.6823 0.5282 0.6481
## tp fn fp tn
## 365 380 326 700
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 0.6931472 1.791759 2.564949 2.646941 3.295837 4.803987 8.040769
## 0 0 0.6931472 1.791759 2.397895 2.467816 3.091042 4.427823 7.767687
## 1 0 1.0986123 1.945910 2.833213 2.893629 3.583519 5.388902 8.040769
## SD NAs
## 1.227127 0
## 1.123296 0
## 1.318674 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.30 2.77 2.77 2.89 2.88 2.89 3.09 3.43 0.12 0
## AUC_b 0.54 0.57 0.59 0.60 0.60 0.60 0.62 0.64 0.01 0
## AUC_oob 0.54 0.57 0.58 0.60 0.60 0.61 0.63 0.65 0.02 0
## sum_sens_spec_b 1.09 1.14 1.16 1.18 1.18 1.19 1.21 1.24 0.02 0
## sum_sens_spec_oob 1.05 1.11 1.14 1.16 1.16 1.18 1.21 1.25 0.03 0
## acc_b 0.55 0.58 0.59 0.60 0.60 0.61 0.62 0.65 0.01 0
## acc_oob 0.50 0.57 0.58 0.59 0.59 0.61 0.62 0.64 0.02 0
## sensitivity_b 0.29 0.41 0.48 0.50 0.50 0.52 0.55 0.70 0.05 0
## sensitivity_oob 0.27 0.38 0.47 0.49 0.49 0.52 0.55 0.70 0.05 0
## specificity_b 0.45 0.63 0.65 0.68 0.68 0.70 0.76 0.85 0.04 0
## specificity_oob 0.37 0.61 0.65 0.67 0.67 0.69 0.76 0.85 0.04 0
## cohens_kappa_b 0.09 0.14 0.16 0.18 0.18 0.19 0.21 0.25 0.02 0
## cohens_kappa_oob 0.05 0.11 0.14 0.16 0.16 0.18 0.21 0.26 0.03 0
## ppv_b 0.45 0.50 0.52 0.53 0.53 0.54 0.57 0.64 0.02 0
## ppv_oob 0.44 0.48 0.50 0.52 0.52 0.54 0.56 0.63 0.03 0
## npv_b 0.58 0.62 0.64 0.65 0.65 0.66 0.68 0.69 0.02 0
## npv_oob 0.58 0.61 0.63 0.64 0.64 0.66 0.68 0.71 0.02 0
# ROC plot
plot(LYM.IMI)
# Youden index plot
plot_metric(LYM.IMI)
# %LYM IMI quarter
PER.LYM.IMI <- cutpointr(Doff.by.quarter.2, PERCENT02_N, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.IMI)
## Method: maximize_metric
## Predictor: PERCENT02_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5173 1771 1026 745
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 18.18 1.049 0.5206 0.5 0.549 0.6042 0.4436
## tp fn fp tn
## 513 513 336 409
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0 7.805 13.325 17.760 19.04679 23.7650 34.360 60.00 8.224778 0
## 0 0 7.700 13.330 18.135 19.18767 24.1175 34.330 56.41 8.244352 0
## 1 0 8.052 13.250 17.380 18.85278 23.2900 34.374 60.00 8.199312 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 6.17 15.79 16.10 18.18 18.70 19.51 26.54 45.00 3.32
## AUC_b 0.47 0.49 0.51 0.52 0.52 0.53 0.54 0.58 0.01
## AUC_oob 0.45 0.49 0.51 0.52 0.52 0.53 0.55 0.58 0.02
## sum_sens_spec_b 1.00 1.03 1.05 1.06 1.06 1.08 1.10 1.14 0.02
## sum_sens_spec_oob 0.92 0.97 1.00 1.02 1.02 1.04 1.07 1.11 0.03
## acc_b 0.42 0.47 0.51 0.53 0.53 0.54 0.56 0.59 0.03
## acc_oob 0.41 0.45 0.49 0.51 0.51 0.53 0.54 0.58 0.03
## sensitivity_b 0.01 0.19 0.45 0.51 0.50 0.61 0.65 0.98 0.14
## sensitivity_oob 0.01 0.17 0.43 0.49 0.48 0.59 0.64 0.97 0.14
## specificity_b 0.02 0.41 0.45 0.56 0.56 0.61 0.85 0.99 0.13
## specificity_oob 0.01 0.37 0.43 0.54 0.54 0.59 0.83 0.99 0.14
## cohens_kappa_b 0.00 0.03 0.04 0.06 0.06 0.07 0.10 0.13 0.02
## cohens_kappa_oob -0.08 -0.03 0.00 0.02 0.02 0.04 0.07 0.11 0.03
## ppv_b 0.56 0.59 0.60 0.61 0.61 0.62 0.65 0.70 0.02
## ppv_oob 0.46 0.55 0.58 0.59 0.59 0.61 0.63 0.71 0.02
## npv_b 0.40 0.42 0.44 0.45 0.45 0.46 0.48 0.52 0.02
## npv_oob 0.20 0.39 0.42 0.43 0.43 0.45 0.47 0.51 0.02
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.LYM.IMI)
# Youden index plot
plot_metric(PER.LYM.IMI)
# MAC IMI quarter
MAC.IMI <- cutpointr(Doff.by.quarter.2, log.Mac, IMI, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.IMI)
## Method: maximize_metric
## Predictor: log.Mac
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5804 1771 745 1026
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.9318 1.1242 0.5991 0.3289 0.7953 0.5385 0.6201
## tp fn fp tn
## 245 500 210 816
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 1.098612 2.079442 2.944439 3.082324 3.970292 5.603920 8.582232
## 0 0 1.098612 1.945910 2.772589 2.902256 3.707399 5.199736 8.582232
## 1 0 1.098612 2.197225 3.135494 3.330311 4.317488 6.077632 8.423322
## SD NAs
## 1.431457 0
## 1.329270 0
## 1.527805 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.40 2.48 2.83 3.26 3.33 3.89 4.01 4.84 0.57 0
## AUC_b 0.54 0.56 0.57 0.58 0.58 0.59 0.60 0.63 0.01 0
## AUC_oob 0.52 0.55 0.57 0.58 0.58 0.59 0.61 0.64 0.02 0
## sum_sens_spec_b 1.07 1.10 1.12 1.14 1.14 1.15 1.17 1.22 0.02 0
## sum_sens_spec_oob 0.99 1.05 1.08 1.10 1.10 1.12 1.15 1.18 0.03 0
## acc_b 0.51 0.54 0.56 0.58 0.58 0.60 0.62 0.64 0.03 0
## acc_oob 0.47 0.52 0.54 0.56 0.56 0.59 0.61 0.63 0.03 0
## sensitivity_b 0.19 0.31 0.35 0.49 0.49 0.62 0.72 0.77 0.15 0
## sensitivity_oob 0.12 0.29 0.33 0.45 0.47 0.60 0.70 0.76 0.15 0
## specificity_b 0.35 0.41 0.52 0.65 0.65 0.79 0.82 0.92 0.15 0
## specificity_oob 0.32 0.40 0.50 0.63 0.63 0.77 0.81 0.93 0.15 0
## cohens_kappa_b 0.07 0.10 0.12 0.14 0.14 0.15 0.17 0.21 0.02 0
## cohens_kappa_oob -0.01 0.05 0.08 0.10 0.10 0.12 0.15 0.19 0.03 0
## ppv_b 0.43 0.46 0.48 0.51 0.51 0.54 0.57 0.66 0.04 0
## ppv_oob 0.40 0.44 0.46 0.48 0.49 0.52 0.56 0.62 0.04 0
## npv_b 0.58 0.61 0.62 0.64 0.64 0.65 0.68 0.71 0.02 0
## npv_oob 0.55 0.59 0.61 0.62 0.62 0.64 0.66 0.70 0.02 0
# ROC plot
plot(MAC.IMI)
# Youden index plot
plot_metric(MAC.IMI)
# %MAC IMI COW
PER.MAC.IMI <- cutpointr(Doff.by.quarter.2, PERCENT03_N, IMI, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.IMI)
## Method: maximize_metric
## Predictor: PERCENT03_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5085 1771 1026 745
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 25.3 1.0483 0.5381 0.6121 0.4362 0.5992 0.4495
## tp fn fp tn
## 628 398 420 325
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.00 9.720 19.355 29.350 30.64550 40.0000 57.615 83.54 14.58798 0
## 0 0.00 9.760 19.570 29.605 30.76740 39.8025 57.470 83.54 14.50642 0
## 1 1.64 9.728 19.120 28.800 30.47762 40.8000 57.582 73.41 14.70768 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 2.94 21.21 21.82 25.30 25.26 26.59 33.01 74.37 5.54
## AUC_b 0.46 0.49 0.50 0.51 0.51 0.52 0.53 0.56 0.01
## AUC_oob 0.45 0.48 0.50 0.51 0.51 0.52 0.54 0.57 0.02
## sum_sens_spec_b 1.00 1.02 1.04 1.06 1.06 1.07 1.10 1.13 0.02
## sum_sens_spec_oob 0.91 0.97 1.01 1.03 1.03 1.05 1.08 1.13 0.03
## acc_b 0.42 0.51 0.54 0.55 0.54 0.56 0.57 0.60 0.02
## acc_oob 0.39 0.48 0.52 0.53 0.53 0.54 0.56 0.59 0.03
## sensitivity_b 0.00 0.43 0.59 0.62 0.62 0.70 0.73 0.99 0.11
## sensitivity_oob 0.00 0.40 0.57 0.61 0.61 0.69 0.73 1.00 0.11
## specificity_b 0.02 0.32 0.36 0.44 0.43 0.47 0.62 1.00 0.11
## specificity_oob 0.00 0.30 0.34 0.42 0.41 0.46 0.58 1.00 0.11
## cohens_kappa_b 0.00 0.02 0.04 0.06 0.06 0.07 0.10 0.14 0.02
## cohens_kappa_oob -0.09 -0.03 0.01 0.03 0.03 0.05 0.08 0.13 0.03
## ppv_b 0.56 0.58 0.59 0.60 0.61 0.61 0.63 1.00 0.03
## ppv_oob 0.38 0.55 0.58 0.59 0.59 0.60 0.62 1.00 0.03
## npv_b 0.40 0.43 0.44 0.46 0.46 0.47 0.49 0.67 0.02
## npv_oob 0.26 0.39 0.42 0.44 0.44 0.46 0.48 0.53 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 1
# ROC plot
plot(PER.MAC.IMI)
# Youden index plot
plot_metric(PER.MAC.IMI)
# Summary of results when using IMI as reference
print(c("Optimal SCC:", exp(SCC.IMI$optimal_cutpoint), SCC.IMI$sensitivity, SCC.IMI$specificity, SCC.IMI$ppv, SCC.IMI$npv, SCC.IMI$AUC))
## sensitivity specificity
## "Optimal SCC:" "95" "0.485981308411215" "0.663433559650824"
##
## "0.511954992967651" "0.639850327408793" "0.587602739637331"
print(c("Optimal n NEU:", exp(NEU.IMI$optimal_cutpoint), NEU.IMI$sensitivity, NEU.IMI$specificity, NEU.IMI$ppv, NEU.IMI$npv, NEU.IMI$AUC))
## sensitivity specificity
## "Optimal n NEU:" "58" "0.405369127516779" "0.754385964912281"
##
## "0.545126353790614" "0.635990139687757" "0.593420071431375"
print(c("Optimal %NEU:", PER.NEU.IMI$optimal_cutpoint, PER.NEU.IMI$sensitivity, PER.NEU.IMI$specificity, PER.NEU.IMI$ppv, PER.NEU.IMI$npv, PER.NEU.IMI$AUC))
## sensitivity specificity
## "Optimal %NEU:" "61.02" "0.224161073825503" "0.825536062378168"
##
## "0.482658959537572" "0.594385964912281" "0.515860120098905"
print(c("Optimal n LYM:", exp(LYM.IMI$optimal_cutpoint), LYM.IMI$sensitivity, LYM.IMI$specificity, LYM.IMI$ppv, LYM.IMI$npv, LYM.IMI$AUC))
## sensitivity specificity
## "Optimal n LYM:" "18" "0.48993288590604" "0.682261208576998"
##
## "0.52821997105644" "0.648148148148148" "0.595650012428536"
print(c("Optimal %LYM:", PER.LYM.IMI$optimal_cutpoint, PER.LYM.IMI$sensitivity, PER.LYM.IMI$specificity, PER.LYM.IMI$ppv, PER.LYM.IMI$npv, PER.LYM.IMI$AUC))
## sensitivity specificity
## "Optimal %LYM:" "18.18" "0.5" "0.548993288590604"
##
## "0.604240282685512" "0.443600867678959" "0.517328649737692"
print(c("Optimal n MAC:", exp(MAC.IMI$optimal_cutpoint), MAC.IMI$sensitivity, MAC.IMI$specificity, MAC.IMI$ppv, MAC.IMI$npv, MAC.IMI$AUC))
## sensitivity specificity
## "Optimal n MAC:" "51" "0.328859060402685" "0.795321637426901"
##
## "0.538461538461538" "0.620060790273556" "0.580438792731269"
print(c("Optimal %MAC:", PER.MAC.IMI$optimal_cutpoint, PER.MAC.IMI$sensitivity, PER.MAC.IMI$specificity, PER.MAC.IMI$ppv, PER.MAC.IMI$npv, PER.MAC.IMI$AUC))
## sensitivity specificity
## "Optimal %MAC:" "25.3" "0.612085769980507" "0.436241610738255"
##
## "0.599236641221374" "0.449515905947441" "0.508510930570274"
# CI using bootstrapping
# SCC
SCC.IMI.quarter_optimal_cutpoint <- boot_ci(SCC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
SCC.IMI.quarter_lower_ci <- subset(SCC.IMI.quarter_optimal_cutpoint, SCC.IMI.quarter_optimal_cutpoint$quantile == 0.025)$values
exp(SCC.IMI.quarter_lower_ci)
## [1] 79
SCC.IMI.quarter_upper_ci <- subset(SCC.IMI.quarter_optimal_cutpoint, SCC.IMI.quarter_optimal_cutpoint$quantile == 0.975)$values
exp(SCC.IMI.quarter_upper_ci)
## [1] 202
boot_ci(SCC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.285
## 2 0.975 0.574
boot_ci(SCC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.587
## 2 0.975 0.862
boot_ci(SCC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.484
## 2 0.975 0.615
boot_ci(SCC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.608
## 2 0.975 0.671
boot_ci(SCC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.560
## 2 0.975 0.614
# Number neu
NEU.IMI.quarter_optimal_cutpoint <- boot_ci(NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.IMI.quarter_lower_ci <- subset(NEU.IMI.quarter_optimal_cutpoint, NEU.IMI.quarter_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.IMI.quarter_lower_ci)
## [1] 35
NEU.IMI.quarter_upper_ci <- subset(NEU.IMI.quarter_optimal_cutpoint, NEU.IMI.quarter_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.IMI.quarter_upper_ci)
## [1] 69.02483
boot_ci(NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.342
## 2 0.975 0.570
boot_ci(NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.593
## 2 0.975 0.815
boot_ci(NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.490
## 2 0.975 0.598
boot_ci(NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.612
## 2 0.975 0.672
boot_ci(NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.568
## 2 0.975 0.621
# Percent neu
PER.NEU.IMI.quarter_optimal_cutpoint <- boot_ci(PER.NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.IMI.quarter_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 47.4
## 2 0.975 65.2
PER.NEU.IMI.quarter_lower_ci <- subset(PER.NEU.IMI.quarter_optimal_cutpoint, PER.NEU.IMI.quarter_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.IMI.quarter_upper_ci <- subset(PER.NEU.IMI.quarter_optimal_cutpoint, PER.NEU.IMI.quarter_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.146
## 2 0.975 0.637
boot_ci(PER.NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.431
## 2 0.975 0.899
boot_ci(PER.NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.426
## 2 0.975 0.535
boot_ci(PER.NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.574
## 2 0.975 0.635
boot_ci(PER.NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.489
## 2 0.975 0.544
# Number lym
LYM.IMI.quarter_optimal_cutpoint <- boot_ci(LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.IMI.quarter_lower_ci <- subset(LYM.IMI.quarter_optimal_cutpoint, LYM.IMI.quarter_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.IMI.quarter_lower_ci)
## [1] 16
LYM.IMI.quarter_upper_ci <- subset(LYM.IMI.quarter_optimal_cutpoint, LYM.IMI.quarter_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.IMI.quarter_upper_ci)
## [1] 27
boot_ci(LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.352
## 2 0.975 0.561
boot_ci(LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.618
## 2 0.975 0.813
boot_ci(LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.491
## 2 0.975 0.576
boot_ci(LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.620
## 2 0.975 0.680
boot_ci(LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.567
## 2 0.975 0.623
# Percent lym
PER.LYM.IMI.quarter_optimal_cutpoint <- boot_ci(PER.LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.IMI.quarter_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 15.4
## 2 0.975 28
PER.LYM.IMI.quarter_lower_ci <- subset(PER.LYM.IMI.quarter_optimal_cutpoint, PER.LYM.IMI.quarter_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.IMI.quarter_upper_ci <- subset(PER.LYM.IMI.quarter_optimal_cutpoint, PER.LYM.IMI.quarter_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.160
## 2 0.975 0.668
boot_ci(PER.LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.392
## 2 0.975 0.879
boot_ci(PER.LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.580
## 2 0.975 0.659
boot_ci(PER.LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.419
## 2 0.975 0.488
boot_ci(PER.LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.490
## 2 0.975 0.544
# Number mac
MAC.IMI.quarter_optimal_cutpoint <- boot_ci(MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.IMI.quarter_lower_ci <- subset(MAC.IMI.quarter_optimal_cutpoint, MAC.IMI.quarter_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.IMI.quarter_lower_ci)
## [1] 12
MAC.IMI.quarter_upper_ci <- subset(MAC.IMI.quarter_optimal_cutpoint, MAC.IMI.quarter_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.IMI.quarter_upper_ci)
## [1] 57
boot_ci(MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.297
## 2 0.975 0.733
boot_ci(MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.398
## 2 0.975 0.826
boot_ci(MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.456
## 2 0.975 0.581
boot_ci(MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.604
## 2 0.975 0.686
boot_ci(MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.554
## 2 0.975 0.607
# Percent mac
PER.MAC.IMI.quarter_optimal_cutpoint <- boot_ci(PER.MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.IMI.quarter_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 20.7
## 2 0.975 36.7
PER.MAC.IMI.quarter_lower_ci <- subset(PER.MAC.IMI.quarter_optimal_cutpoint, PER.MAC.IMI.quarter_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.IMI.quarter_upper_ci <- subset(PER.MAC.IMI.quarter_optimal_cutpoint, PER.MAC.IMI.quarter_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.339
## 2 0.975 0.742
boot_ci(PER.MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.309
## 2 0.975 0.700
boot_ci(PER.MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.576
## 2 0.975 0.638
boot_ci(PER.MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.421
## 2 0.975 0.499
boot_ci(PER.MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.481
## 2 0.975 0.536
# Prevalence
# True prevalence
table(Doff.by.quarter.2$IMI)
##
## 0 1
## 1034 750
prop.table(table(Doff.by.quarter.2$IMI))
##
## 0 1
## 0.5795964 0.4204036
#Apparent prevalence
# ---- SCC ----
# optimal cut-off
optimal_scc_doff_IMI_quarter <- SCC.IMI$optimal_cutpoint
table(Doff.by.quarter.2$test_result_n > exp(optimal_scc_doff_IMI_quarter))
##
## FALSE TRUE
## 1145 756
prop.table(table(Doff.by.quarter.2$test_result_n > exp(optimal_scc_doff_IMI_quarter)))
##
## FALSE TRUE
## 0.6023146 0.3976854
# confidence intervals
table(Doff.by.quarter.2$test_result_n > exp(SCC.IMI.quarter_lower_ci))
##
## FALSE TRUE
## 1015 886
prop.table(table(Doff.by.quarter.2$test_result_n > exp(SCC.IMI.quarter_lower_ci)))
##
## FALSE TRUE
## 0.5339295 0.4660705
table(Doff.by.quarter.2$test_result_n > exp(SCC.IMI.quarter_upper_ci))
##
## FALSE TRUE
## 1533 368
prop.table(table(Doff.by.quarter.2$test_result_n >exp(SCC.IMI.quarter_upper_ci)))
##
## FALSE TRUE
## 0.8064177 0.1935823
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_doff_IMI_quarter <- NEU.IMI$optimal_cutpoint
table(Doff.by.quarter.2$TOTAL01_N > exp(optimal_neu_doff_IMI_quarter))
##
## FALSE TRUE
## 1291 599
prop.table(table(Doff.by.quarter.2$TOTAL01_N > exp(optimal_neu_doff_IMI_quarter)))
##
## FALSE TRUE
## 0.6830688 0.3169312
# confidence intervals
table(Doff.by.quarter.2$TOTAL01_N > exp(NEU.IMI.quarter_lower_ci))
##
## FALSE TRUE
## 986 904
prop.table(table(Doff.by.quarter.2$TOTAL01_N > exp(NEU.IMI.quarter_lower_ci)))
##
## FALSE TRUE
## 0.5216931 0.4783069
table(Doff.by.quarter.2$TOTAL01_N > exp(NEU.IMI.quarter_upper_ci))
##
## FALSE TRUE
## 1384 506
prop.table(table(Doff.by.quarter.2$TOTAL01_N >exp(NEU.IMI.quarter_upper_ci)))
##
## FALSE TRUE
## 0.7322751 0.2677249
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_doff_IMI_quarter <- PER.NEU.IMI$optimal_cutpoint
table(Doff.by.quarter.2$PERCENT01_N > optimal_per_neu_doff_IMI_quarter)
##
## FALSE TRUE
## 1524 366
prop.table(table(Doff.by.quarter.2$PERCENT01_N > optimal_per_neu_doff_IMI_quarter))
##
## FALSE TRUE
## 0.8063492 0.1936508
# confidence intervals
table(Doff.by.quarter.2$PERCENT01_N > PER.NEU.IMI.quarter_lower_ci)
##
## FALSE TRUE
## 768 1122
prop.table(table(Doff.by.quarter.2$PERCENT01_N > PER.NEU.IMI.quarter_lower_ci))
##
## FALSE TRUE
## 0.4063492 0.5936508
table(Doff.by.quarter.2$PERCENT01_N > PER.NEU.IMI.quarter_upper_ci)
##
## FALSE TRUE
## 1674 216
prop.table(table(Doff.by.quarter.2$PERCENT01_N >PER.NEU.IMI.quarter_upper_ci))
##
## FALSE TRUE
## 0.8857143 0.1142857
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_doff_IMI_quarter <-LYM.IMI$optimal_cutpoint
table(Doff.by.quarter.2$TOTAL02_N > exp(optimal_lym_doff_IMI_quarter))
##
## FALSE TRUE
## 1145 745
prop.table(table(Doff.by.quarter.2$TOTAL02_N > exp(optimal_lym_doff_IMI_quarter)))
##
## FALSE TRUE
## 0.6058201 0.3941799
# confidence intervals
table(Doff.by.quarter.2$TOTAL02_N > exp(LYM.IMI.quarter_lower_ci))
##
## FALSE TRUE
## 1067 823
prop.table(table(Doff.by.quarter.2$TOTAL02_N > exp(LYM.IMI.quarter_lower_ci)))
##
## FALSE TRUE
## 0.5645503 0.4354497
table(Doff.by.quarter.2$TOTAL02_N > exp(LYM.IMI.quarter_upper_ci))
##
## FALSE TRUE
## 1417 473
prop.table(table(Doff.by.quarter.2$TOTAL02_N >exp(LYM.IMI.quarter_upper_ci)))
##
## FALSE TRUE
## 0.7497354 0.2502646
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_doff_IMI_quarter <-PER.LYM.IMI$optimal_cutpoint
table(Doff.by.quarter.2$PERCENT02_N > optimal_per_lym_doff_IMI_quarter)
##
## FALSE TRUE
## 985 905
prop.table(table(Doff.by.quarter.2$PERCENT02_N > optimal_per_lym_doff_IMI_quarter))
##
## FALSE TRUE
## 0.521164 0.478836
# confidence intervals
table(Doff.by.quarter.2$PERCENT02_N > PER.LYM.IMI.quarter_lower_ci)
##
## FALSE TRUE
## 667 1223
prop.table(table(Doff.by.quarter.2$PERCENT02_N > PER.LYM.IMI.quarter_lower_ci))
##
## FALSE TRUE
## 0.3529101 0.6470899
table(Doff.by.quarter.2$PERCENT02_N > PER.LYM.IMI.quarter_upper_ci)
##
## FALSE TRUE
## 1626 264
prop.table(table(Doff.by.quarter.2$PERCENT02_N >PER.LYM.IMI.quarter_upper_ci))
##
## FALSE TRUE
## 0.8603175 0.1396825
# ---- Macrophages ----
# optimal cut-off
optimal_mac_doff_IMI_quarter <- MAC.IMI$optimal_cutpoint
table(Doff.by.quarter.2$TOTAL03_N > exp(optimal_mac_doff_IMI_quarter))
##
## FALSE TRUE
## 1411 479
prop.table(table(Doff.by.quarter.2$TOTAL03_N > exp(optimal_mac_doff_IMI_quarter)))
##
## FALSE TRUE
## 0.7465608 0.2534392
# confidence intervals
table(Doff.by.quarter.2$TOTAL03_N > exp(MAC.IMI.quarter_lower_ci))
##
## FALSE TRUE
## 721 1169
prop.table(table(Doff.by.quarter.2$TOTAL03_N > exp(MAC.IMI.quarter_lower_ci)))
##
## FALSE TRUE
## 0.3814815 0.6185185
table(Doff.by.quarter.2$TOTAL03_N > exp(MAC.IMI.quarter_upper_ci))
##
## FALSE TRUE
## 1443 447
prop.table(table(Doff.by.quarter.2$TOTAL03_N >exp(MAC.IMI.quarter_upper_ci)))
##
## FALSE TRUE
## 0.7634921 0.2365079
# Percent MAC
# optimal cut-off
optimal_per_mac_doff_IMI_quarter <- PER.MAC.IMI$optimal_cutpoint
table(Doff.by.quarter.2$PERCENT03_N > optimal_per_mac_doff_IMI_quarter)
##
## FALSE TRUE
## 779 1111
prop.table(table(Doff.by.quarter.2$PERCENT03_N > optimal_per_mac_doff_IMI_quarter))
##
## FALSE TRUE
## 0.4121693 0.5878307
# confidence intervals
table(Doff.by.quarter.2$PERCENT03_N > PER.MAC.IMI.quarter_lower_ci)
##
## FALSE TRUE
## 544 1346
prop.table(table(Doff.by.quarter.2$PERCENT03_N > PER.MAC.IMI.quarter_lower_ci))
##
## FALSE TRUE
## 0.2878307 0.7121693
table(Doff.by.quarter.2$PERCENT03_N > PER.MAC.IMI.quarter_upper_ci)
##
## FALSE TRUE
## 1277 613
prop.table(table(Doff.by.quarter.2$PERCENT03_N >PER.MAC.IMI.quarter_upper_ci))
##
## FALSE TRUE
## 0.6756614 0.3243386
# Set a seed for reproducibility
set.seed(123)
# Qscout subclinical mastitis reference
# n NEU SCM quarter
NEU.delaval.SCM <- cutpointr(Doff.by.quarter.2, log.Neu, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Neu
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9671 1886 371 1515
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 4.3175 1.8387 0.9162 0.9245 0.9142 0.7252 0.9802
## tp fn fp tn
## 343 28 130 1385
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.6931472 2.079442 2.772589 3.496508 3.685987 4.317488 6.012472
## 0 0.6931472 1.945910 2.673554 3.258097 3.238194 3.806662 4.532599
## 1 2.0794415 4.127134 4.803987 5.231109 5.514573 6.017375 7.957542
## Max. SD NAs
## 9.342946 1.2632571 0
## 7.330405 0.7930368 0
## 9.342946 1.1759344 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 4.11 4.28 4.32 4.32 4.33 4.34 4.37 4.66 0.04 0
## AUC_b 0.95 0.96 0.96 0.97 0.97 0.97 0.98 0.98 0.01 0
## AUC_oob 0.94 0.95 0.96 0.97 0.97 0.97 0.98 0.99 0.01 0
## sum_sens_spec_b 1.79 1.82 1.83 1.84 1.84 1.85 1.86 1.89 0.01 0
## sum_sens_spec_oob 1.72 1.79 1.82 1.83 1.83 1.85 1.87 1.90 0.02 0
## acc_b 0.87 0.90 0.91 0.92 0.92 0.92 0.93 0.95 0.01 0
## acc_oob 0.86 0.90 0.91 0.92 0.91 0.92 0.93 0.95 0.01 0
## sensitivity_b 0.86 0.90 0.92 0.92 0.92 0.93 0.95 0.97 0.01 0
## sensitivity_oob 0.76 0.88 0.90 0.92 0.92 0.93 0.95 0.98 0.02 0
## specificity_b 0.85 0.90 0.91 0.92 0.92 0.92 0.93 0.97 0.01 0
## specificity_oob 0.84 0.89 0.91 0.92 0.91 0.92 0.93 0.96 0.01 0
## cohens_kappa_b 0.66 0.73 0.75 0.76 0.76 0.78 0.79 0.85 0.02 0
## cohens_kappa_oob 0.65 0.71 0.74 0.76 0.76 0.77 0.80 0.84 0.03 0
## ppv_b 0.59 0.69 0.71 0.73 0.73 0.75 0.77 0.89 0.03 0
## ppv_oob 0.60 0.67 0.71 0.73 0.73 0.75 0.78 0.85 0.03 0
## npv_b 0.96 0.97 0.98 0.98 0.98 0.98 0.99 0.99 0.00 0
## npv_oob 0.94 0.97 0.97 0.98 0.98 0.98 0.99 0.99 0.01 0
# ROC plot
plot(NEU.delaval.SCM)
# Youden index plot
plot_metric(NEU.delaval.SCM)
# %NEU SCM quarter
PER.NEU.delaval.SCM <- cutpointr(Doff.by.quarter.2, PERCENT01_N, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT01_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5144 1886 371 1515
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 58.7 1.1107 0.6813 0.3477 0.763 0.2643 0.8269
## tp fn fp tn
## 129 242 359 1156
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 13.06 29.9925 41.980 50.00 50.35406 58.895 69.7675 85.71 12.06358
## 0 15.10 30.8570 42.410 50.00 50.28239 58.080 69.1300 85.71 11.45665
## 1 13.06 26.4800 39.155 50.89 50.64674 62.280 72.3100 83.51 14.29086
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 53.45 57.74 58.70 58.71 60.33 62.62 64.17 70.86 2.51
## AUC_b 0.46 0.48 0.50 0.51 0.51 0.53 0.54 0.57 0.02
## AUC_oob 0.44 0.47 0.50 0.51 0.51 0.53 0.55 0.59 0.02
## sum_sens_spec_b 1.03 1.08 1.10 1.12 1.12 1.13 1.16 1.20 0.02
## sum_sens_spec_oob 0.95 1.04 1.07 1.09 1.09 1.11 1.14 1.22 0.03
## acc_b 0.57 0.66 0.68 0.69 0.71 0.74 0.76 0.80 0.04
## acc_oob 0.54 0.65 0.67 0.69 0.70 0.73 0.76 0.80 0.04
## sensitivity_b 0.09 0.21 0.25 0.34 0.31 0.37 0.40 0.52 0.07
## sensitivity_oob 0.05 0.18 0.23 0.31 0.29 0.35 0.38 0.46 0.07
## specificity_b 0.58 0.74 0.76 0.77 0.80 0.86 0.89 0.97 0.06
## specificity_oob 0.57 0.72 0.75 0.77 0.80 0.86 0.89 0.97 0.06
## cohens_kappa_b 0.03 0.08 0.10 0.11 0.11 0.13 0.15 0.21 0.02
## cohens_kappa_oob -0.03 0.03 0.07 0.09 0.09 0.11 0.14 0.22 0.03
## ppv_b 0.21 0.24 0.26 0.28 0.29 0.31 0.35 0.43 0.03
## ppv_oob 0.16 0.22 0.24 0.26 0.27 0.29 0.33 0.45 0.04
## npv_b 0.79 0.81 0.82 0.83 0.83 0.83 0.84 0.86 0.01
## npv_oob 0.78 0.80 0.81 0.82 0.82 0.83 0.84 0.86 0.01
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.delaval.SCM)
# Youden index plot
plot_metric(PER.NEU.delaval.SCM)
# LYM SCM quarter
LYM.delaval.SCM <- cutpointr(Doff.by.quarter.2, log.Lym, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Lym
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9554 1886 371 1515
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.3322 1.7917 0.9014 0.8868 0.905 0.6956 0.9703
## tp fn fp tn
## 329 42 144 1371
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.0000000 0.7945135 1.791759 2.564949 2.659278 3.332205 4.818257
## 0 0.0000000 0.6931472 1.609438 2.302585 2.250548 2.890372 3.555348
## 1 0.6931472 2.8903718 3.688879 4.248495 4.328348 4.835998 6.326047
## Max. SD NAs
## 8.040769 1.2220077 0
## 6.612041 0.8668058 0
## 8.040769 1.0275960 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.09 3.22 3.26 3.33 3.31 3.33 3.43 3.66 0.06 0
## AUC_b 0.93 0.94 0.95 0.96 0.96 0.96 0.97 0.97 0.01 0
## AUC_oob 0.93 0.94 0.95 0.96 0.96 0.96 0.97 0.98 0.01 0
## sum_sens_spec_b 1.73 1.77 1.78 1.79 1.79 1.81 1.82 1.85 0.02 0
## sum_sens_spec_oob 1.68 1.74 1.76 1.78 1.78 1.80 1.82 1.87 0.03 0
## acc_b 0.85 0.88 0.89 0.90 0.90 0.91 0.92 0.94 0.01 0
## acc_oob 0.82 0.87 0.89 0.90 0.89 0.90 0.91 0.93 0.01 0
## sensitivity_b 0.81 0.86 0.88 0.90 0.89 0.91 0.93 0.95 0.02 0
## sensitivity_oob 0.72 0.83 0.87 0.89 0.89 0.91 0.93 0.96 0.03 0
## specificity_b 0.83 0.87 0.89 0.90 0.90 0.91 0.92 0.97 0.02 0
## specificity_oob 0.80 0.86 0.88 0.90 0.90 0.91 0.93 0.97 0.02 0
## cohens_kappa_b 0.60 0.67 0.69 0.71 0.71 0.73 0.76 0.81 0.03 0
## cohens_kappa_oob 0.55 0.65 0.68 0.70 0.70 0.72 0.75 0.79 0.03 0
## ppv_b 0.56 0.63 0.66 0.69 0.69 0.71 0.75 0.85 0.04 0
## ppv_oob 0.51 0.61 0.65 0.68 0.68 0.71 0.75 0.86 0.04 0
## npv_b 0.95 0.96 0.97 0.97 0.97 0.98 0.98 0.99 0.01 0
## npv_oob 0.93 0.96 0.97 0.97 0.97 0.98 0.98 0.99 0.01 0
# ROC plot
plot(LYM.delaval.SCM)
# Youden index plot
plot_metric(LYM.delaval.SCM)
# %LYM SCM quarter
PER.LYM.delaval.SCM <- cutpointr(Doff.by.quarter.2, PERCENT02_N, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT02_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.6399 1886 1515 371
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 19.72 1.2379 0.517 0.4508 0.7871 0.8963 0.2598 683
## fn fp tn
## 832 79 292
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.0 7.8925 13.465 17.84 19.11998 23.810 34.370 60.00 8.135124 0
## 0 0.0 8.2970 14.005 18.60 19.89336 24.840 35.234 60.00 8.391717 0
## 1 2.8 7.2150 11.505 15.70 15.96186 19.275 26.115 48.54 6.046239 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 12.70 19.21 19.72 19.83 20.21 20.69 21.67 23.44 0.91
## AUC_b 0.58 0.62 0.63 0.64 0.64 0.65 0.66 0.69 0.01
## AUC_oob 0.57 0.61 0.63 0.64 0.64 0.65 0.67 0.70 0.02
## sum_sens_spec_b 1.16 1.21 1.23 1.24 1.24 1.26 1.28 1.33 0.02
## sum_sens_spec_oob 1.04 1.17 1.20 1.22 1.22 1.24 1.27 1.35 0.03
## acc_b 0.40 0.46 0.49 0.51 0.51 0.52 0.54 0.75 0.03
## acc_oob 0.40 0.45 0.48 0.50 0.50 0.52 0.54 0.69 0.03
## sensitivity_b 0.29 0.37 0.41 0.44 0.43 0.46 0.48 0.83 0.04
## sensitivity_oob 0.27 0.36 0.40 0.43 0.43 0.45 0.48 0.81 0.04
## specificity_b 0.40 0.75 0.79 0.81 0.81 0.84 0.87 0.93 0.04
## specificity_oob 0.25 0.71 0.77 0.79 0.79 0.82 0.87 0.92 0.05
## cohens_kappa_b 0.08 0.11 0.12 0.14 0.14 0.15 0.16 0.21 0.02
## cohens_kappa_oob 0.03 0.09 0.11 0.12 0.12 0.13 0.15 0.20 0.02
## ppv_b 0.85 0.88 0.89 0.90 0.90 0.91 0.93 0.95 0.01
## ppv_oob 0.78 0.86 0.88 0.89 0.89 0.91 0.92 0.95 0.02
## npv_b 0.22 0.24 0.25 0.26 0.26 0.27 0.28 0.35 0.01
## npv_oob 0.20 0.23 0.24 0.25 0.25 0.27 0.28 0.31 0.02
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.LYM.delaval.SCM)
# Youden index plot
plot_metric(PER.LYM.delaval.SCM)
# MAC SCM quarter
MAC.delaval.SCM <- cutpointr(Doff.by.quarter.2, log.Mac, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Mac
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9469 1886 371 1515
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.989 1.7769 0.8977 0.8733 0.9036 0.6894 0.9668
## tp fn fp tn
## 324 47 146 1369
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.098612 2.079442 2.944439 3.086039 3.970292 5.574891
## 0 0.000000 1.098612 1.945910 2.564949 2.615936 3.295837 4.343805
## 1 1.098612 3.314021 4.382027 4.962845 5.005731 5.585372 7.015762
## Max. SD NAs
## 8.582232 1.422124 0
## 7.606885 1.042871 0
## 8.582232 1.119449 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.56 3.87 3.87 3.95 3.94 3.99 4.04 4.25 0.07 0
## AUC_b 0.92 0.94 0.94 0.95 0.95 0.95 0.96 0.97 0.01 0
## AUC_oob 0.91 0.93 0.94 0.95 0.95 0.95 0.96 0.98 0.01 0
## sum_sens_spec_b 1.72 1.75 1.77 1.78 1.78 1.79 1.81 1.84 0.02 0
## sum_sens_spec_oob 1.66 1.72 1.75 1.77 1.77 1.79 1.81 1.84 0.02 0
## acc_b 0.84 0.88 0.89 0.89 0.89 0.90 0.91 0.93 0.01 0
## acc_oob 0.83 0.87 0.88 0.89 0.89 0.90 0.91 0.92 0.01 0
## sensitivity_b 0.82 0.85 0.87 0.89 0.89 0.90 0.92 0.95 0.02 0
## sensitivity_oob 0.73 0.82 0.86 0.88 0.88 0.90 0.92 0.95 0.03 0
## specificity_b 0.82 0.87 0.88 0.90 0.90 0.91 0.92 0.95 0.02 0
## specificity_oob 0.80 0.86 0.88 0.89 0.89 0.91 0.92 0.94 0.02 0
## cohens_kappa_b 0.60 0.66 0.68 0.70 0.70 0.72 0.74 0.78 0.03 0
## cohens_kappa_oob 0.56 0.64 0.67 0.69 0.69 0.71 0.73 0.78 0.03 0
## ppv_b 0.56 0.62 0.65 0.68 0.68 0.70 0.73 0.81 0.03 0
## ppv_oob 0.52 0.60 0.64 0.67 0.67 0.69 0.73 0.78 0.04 0
## npv_b 0.95 0.96 0.97 0.97 0.97 0.97 0.98 0.99 0.01 0
## npv_oob 0.93 0.95 0.96 0.97 0.97 0.97 0.98 0.99 0.01 0
# ROC plot
plot(MAC.delaval.SCM)
# Youden index plot
plot_metric(MAC.delaval.SCM)
# %MAC SCM quarter
PER.MAC.delaval.SCM<- cutpointr(Doff.by.quarter.2, PERCENT03_N, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT03_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.553 1886 371 1515
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 47.98 1.1133 0.7635 0.2156 0.8977 0.3404 0.8237 80
## fn fp tn
## 291 155 1360
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.00 9.760 19.400 29.19 30.52581 39.8325 57.125 83.54 14.47232 0
## 0 0.00 9.502 19.165 28.78 29.82450 38.9050 54.515 76.56 13.87512 0
## 1 3.25 11.185 20.045 30.72 33.38965 44.2400 62.690 83.54 16.40269 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 15.59 34.53 40.70 47.58 45.21 48.09 53.04 58.31 5.58
## AUC_b 0.50 0.52 0.54 0.55 0.55 0.56 0.58 0.61 0.02
## AUC_oob 0.48 0.52 0.54 0.55 0.55 0.57 0.59 0.63 0.02
## sum_sens_spec_b 1.05 1.09 1.11 1.12 1.12 1.14 1.16 1.21 0.02
## sum_sens_spec_oob 0.95 1.02 1.06 1.09 1.09 1.11 1.14 1.18 0.04
## acc_b 0.34 0.62 0.70 0.76 0.74 0.77 0.79 0.82 0.06
## acc_oob 0.26 0.59 0.69 0.75 0.72 0.77 0.79 0.82 0.06
## sensitivity_b 0.09 0.16 0.21 0.24 0.27 0.33 0.48 0.92 0.10
## sensitivity_oob 0.06 0.14 0.19 0.22 0.24 0.29 0.41 0.81 0.08
## specificity_b 0.19 0.65 0.79 0.89 0.85 0.90 0.94 0.98 0.09
## specificity_oob 0.13 0.63 0.78 0.89 0.84 0.90 0.94 0.98 0.10
## cohens_kappa_b 0.03 0.08 0.11 0.13 0.13 0.15 0.17 0.22 0.03
## cohens_kappa_oob -0.03 0.02 0.07 0.10 0.09 0.13 0.16 0.21 0.04
## ppv_b 0.20 0.25 0.28 0.33 0.33 0.36 0.42 0.55 0.06
## ppv_oob 0.15 0.20 0.25 0.30 0.30 0.34 0.40 0.56 0.06
## npv_b 0.79 0.81 0.82 0.83 0.83 0.83 0.84 0.91 0.01
## npv_oob 0.75 0.80 0.81 0.82 0.82 0.83 0.84 0.86 0.01
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.MAC.delaval.SCM)
# Youden index plot
plot_metric(PER.MAC.delaval.SCM)
# Summary of results when using SCM as reference
print(c("Optimal n NEU:", exp(NEU.delaval.SCM$optimal_cutpoint), NEU.delaval.SCM$sensitivity, NEU.delaval.SCM$specificity, NEU.delaval.SCM$ppv, NEU.delaval.SCM$npv, NEU.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n NEU:" "75" "0.924528301886792" "0.914191419141914"
##
## "0.725158562367865" "0.980184005661713" "0.967137252808839"
print(c("Optimal %NEU:", PER.NEU.delaval.SCM$optimal_cutpoint, PER.NEU.delaval.SCM$sensitivity, PER.NEU.delaval.SCM$specificity, PER.NEU.delaval.SCM$ppv, PER.NEU.delaval.SCM$npv, PER.NEU.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %NEU:" "58.7" "0.347708894878706" "0.763036303630363"
##
## "0.264344262295082" "0.82689556509299" "0.514406696734363"
print(c("Optimal n LYM:", exp(LYM.delaval.SCM$optimal_cutpoint), LYM.delaval.SCM$sensitivity, LYM.delaval.SCM$specificity, LYM.delaval.SCM$ppv, LYM.delaval.SCM$npv, LYM.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n LYM:" "28" "0.886792452830189" "0.904950495049505"
##
## "0.695560253699789" "0.970276008492569" "0.955351249410655"
print(c("Optimal %LYM:", PER.LYM.delaval.SCM$optimal_cutpoint, PER.LYM.delaval.SCM$sensitivity, PER.LYM.delaval.SCM$specificity, PER.LYM.delaval.SCM$ppv, PER.LYM.delaval.SCM$npv, PER.LYM.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %LYM:" "19.72" "0.450825082508251" "0.787061994609164"
##
## "0.896325459317585" "0.259786476868327" "0.639895741595723"
print(c("Optimal n MAC:", exp(MAC.delaval.SCM$optimal_cutpoint), MAC.delaval.SCM$sensitivity, MAC.delaval.SCM$specificity, MAC.delaval.SCM$ppv, MAC.delaval.SCM$npv, MAC.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n MAC:" "54" "0.873315363881402" "0.903630363036304"
##
## "0.68936170212766" "0.96680790960452" "0.946867355199132"
print(c("Optimal %MAC:", PER.MAC.delaval.SCM$optimal_cutpoint, PER.MAC.delaval.SCM$sensitivity, PER.MAC.delaval.SCM$specificity, PER.MAC.delaval.SCM$ppv, PER.MAC.delaval.SCM$npv, PER.MAC.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %MAC:" "47.98" "0.215633423180593" "0.897689768976898"
##
## "0.340425531914894" "0.82374318594791" "0.55299564996931"
# CI using bootstrapping
# NEU.delaval.SCM
NEU.delaval.SCM_optimal_cutpoint <- boot_ci(NEU.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.delaval.SCM_lower_ci <- subset(NEU.delaval.SCM_optimal_cutpoint, NEU.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.delaval.SCM_lower_ci)
## [1] 68
NEU.delaval.SCM_upper_ci <- subset(NEU.delaval.SCM_optimal_cutpoint, NEU.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.delaval.SCM_upper_ci)
## [1] 80
boot_ci(NEU.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.895
## 2 0.975 0.952
boot_ci(NEU.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.892
## 2 0.975 0.935
boot_ci(NEU.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.673
## 2 0.975 0.781
boot_ci(NEU.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.972
## 2 0.975 0.987
boot_ci(NEU.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.956
## 2 0.975 0.977
# PER.NEU.delaval.SCM
PER.NEU.delaval.SCM_optimal_cutpoint <- boot_ci(PER.NEU.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 57.3
## 2 0.975 65.2
PER.NEU.delaval.SCM_lower_ci <- subset(PER.NEU.delaval.SCM_optimal_cutpoint, PER.NEU.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.delaval.SCM_upper_ci <- subset(PER.NEU.delaval.SCM_optimal_cutpoint, PER.NEU.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.195
## 2 0.975 0.410
boot_ci(PER.NEU.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.730
## 2 0.975 0.903
boot_ci(PER.NEU.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.238
## 2 0.975 0.357
boot_ci(PER.NEU.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.808
## 2 0.975 0.847
boot_ci(PER.NEU.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.479
## 2 0.975 0.551
# LYM.delaval.SCM
LYM.delaval.SCM_optimal_cutpoint <- boot_ci(LYM.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.delaval.SCM_lower_ci <- subset(LYM.delaval.SCM_optimal_cutpoint, LYM.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.delaval.SCM_lower_ci)
## [1] 25
LYM.delaval.SCM_upper_ci <- subset(LYM.delaval.SCM_optimal_cutpoint, LYM.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.delaval.SCM_upper_ci)
## [1] 33
boot_ci(LYM.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.851
## 2 0.975 0.932
boot_ci(LYM.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.865
## 2 0.975 0.939
boot_ci(LYM.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.617
## 2 0.975 0.773
boot_ci(LYM.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.962
## 2 0.975 0.982
boot_ci(LYM.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.942
## 2 0.975 0.967
# PER.LYM.delaval.SCM
PER.LYM.delaval.SCM_optimal_cutpoint <- boot_ci(PER.LYM.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 18.4
## 2 0.975 21.8
PER.LYM.delaval.SCM_lower_ci <- subset(PER.LYM.delaval.SCM_optimal_cutpoint, PER.LYM.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.delaval.SCM_upper_ci <- subset(PER.LYM.delaval.SCM_optimal_cutpoint, PER.LYM.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.356
## 2 0.975 0.513
boot_ci(PER.LYM.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.725
## 2 0.975 0.884
boot_ci(PER.LYM.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.877
## 2 0.975 0.929
boot_ci(PER.LYM.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.234
## 2 0.975 0.285
boot_ci(PER.LYM.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.612
## 2 0.975 0.669
# MAC.delaval.SCM
MAC.delaval.SCM_optimal_cutpoint <- boot_ci(MAC.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.delaval.SCM_lower_ci <- subset(MAC.delaval.SCM_optimal_cutpoint, MAC.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.delaval.SCM_upper_ci)
## [1] 33
MAC.delaval.SCM_upper_ci <- subset(MAC.delaval.SCM_optimal_cutpoint, MAC.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.delaval.SCM_upper_ci)
## [1] 60
boot_ci(MAC.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.846
## 2 0.975 0.924
boot_ci(MAC.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.865
## 2 0.975 0.921
boot_ci(MAC.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.614
## 2 0.975 0.737
boot_ci(MAC.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.960
## 2 0.975 0.980
boot_ci(MAC.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.933
## 2 0.975 0.960
# PER.MAC.delaval.SCM
PER.MAC.delaval.SCM_optimal_cutpoint <- boot_ci(PER.MAC.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 33.5
## 2 0.975 53.3
PER.MAC.delaval.SCM_lower_ci <- subset(PER.MAC.delaval.SCM_optimal_cutpoint, PER.MAC.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.delaval.SCM_upper_ci <- subset(PER.MAC.delaval.SCM_optimal_cutpoint, PER.MAC.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.145
## 2 0.975 0.500
boot_ci(PER.MAC.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.627
## 2 0.975 0.950
boot_ci(PER.MAC.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.237
## 2 0.975 0.450
boot_ci(PER.MAC.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.808
## 2 0.975 0.847
boot_ci(PER.MAC.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.518
## 2 0.975 0.586
# Prevalence
# True prevalence
table(Doff.by.quarter.2$delaval.SCM)
##
## 0 1
## 1529 372
prop.table(table(Doff.by.quarter.2$delaval.SCM))
##
## 0 1
## 0.8043135 0.1956865
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_doff_delaval.SCM_quarter <- NEU.delaval.SCM$optimal_cutpoint
table(Doff.by.quarter.2$TOTAL01_N > exp(optimal_neu_doff_delaval.SCM_quarter))
##
## FALSE TRUE
## 1417 473
prop.table(table(Doff.by.quarter.2$TOTAL01_N > exp(optimal_neu_doff_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.7497354 0.2502646
# confidence intervals
table(Doff.by.quarter.2$TOTAL01_N > exp(NEU.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1381 509
prop.table(table(Doff.by.quarter.2$TOTAL01_N > exp(NEU.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.7306878 0.2693122
table(Doff.by.quarter.2$TOTAL01_N > exp(NEU.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1440 450
prop.table(table(Doff.by.quarter.2$TOTAL01_N >exp(NEU.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7619048 0.2380952
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_doff_delaval.SCM_quarter <- PER.NEU.delaval.SCM$optimal_cutpoint
table(Doff.by.quarter.2$PERCENT01_N > optimal_per_neu_doff_delaval.SCM_quarter)
##
## FALSE TRUE
## 1405 485
prop.table(table(Doff.by.quarter.2$PERCENT01_N > optimal_per_neu_doff_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.7433862 0.2566138
# confidence intervals
table(Doff.by.quarter.2$PERCENT01_N > PER.NEU.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 1342 548
prop.table(table(Doff.by.quarter.2$PERCENT01_N > PER.NEU.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.7100529 0.2899471
table(Doff.by.quarter.2$PERCENT01_N > PER.NEU.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 1675 215
prop.table(table(Doff.by.quarter.2$PERCENT01_N >PER.NEU.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.8862434 0.1137566
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_doff_delaval.SCM_quarter <-LYM.delaval.SCM$optimal_cutpoint
table(Doff.by.quarter.2$TOTAL02_N > exp(optimal_lym_doff_delaval.SCM_quarter))
##
## FALSE TRUE
## 1417 473
prop.table(table(Doff.by.quarter.2$TOTAL02_N > exp(optimal_lym_doff_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.7497354 0.2502646
# confidence intervals
table(Doff.by.quarter.2$TOTAL02_N > exp(LYM.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1362 528
prop.table(table(Doff.by.quarter.2$TOTAL02_N > exp(LYM.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.7206349 0.2793651
table(Doff.by.quarter.2$TOTAL02_N > exp(LYM.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1504 386
prop.table(table(Doff.by.quarter.2$TOTAL02_N >exp(LYM.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7957672 0.2042328
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_doff_delaval.SCM_quarter <-PER.LYM.delaval.SCM$optimal_cutpoint
table(Doff.by.quarter.2$PERCENT02_N > optimal_per_lym_doff_delaval.SCM_quarter)
##
## FALSE TRUE
## 1129 761
prop.table(table(Doff.by.quarter.2$PERCENT02_N > optimal_per_lym_doff_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.5973545 0.4026455
# confidence intervals
table(Doff.by.quarter.2$PERCENT02_N > PER.LYM.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 997 893
prop.table(table(Doff.by.quarter.2$PERCENT02_N > PER.LYM.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.5275132 0.4724868
table(Doff.by.quarter.2$PERCENT02_N > PER.LYM.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 1293 597
prop.table(table(Doff.by.quarter.2$PERCENT02_N >PER.LYM.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.684127 0.315873
# ---- Macrophages ----
# optimal cut-off
optimal_mac_doff_delaval.SCM_quarter <- MAC.delaval.SCM$optimal_cutpoint
table(Doff.by.quarter.2$TOTAL03_N > exp(optimal_mac_doff_delaval.SCM_quarter))
##
## FALSE TRUE
## 1428 462
prop.table(table(Doff.by.quarter.2$TOTAL03_N > exp(optimal_mac_doff_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.7555556 0.2444444
# confidence intervals
table(Doff.by.quarter.2$TOTAL03_N > exp(MAC.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1381 509
prop.table(table(Doff.by.quarter.2$TOTAL03_N > exp(MAC.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.7306878 0.2693122
table(Doff.by.quarter.2$TOTAL03_N > exp(MAC.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1455 435
prop.table(table(Doff.by.quarter.2$TOTAL03_N >exp(MAC.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7698413 0.2301587
# ---- Percent MAC -----
# optimal cut-off
optimal_per_mac_doff_delaval.SCM_quarter <- PER.MAC.delaval.SCM$optimal_cutpoint
table(Doff.by.quarter.2$PERCENT03_N > optimal_per_mac_doff_delaval.SCM_quarter)
##
## FALSE TRUE
## 1655 235
prop.table(table(Doff.by.quarter.2$PERCENT03_N > optimal_per_mac_doff_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.8756614 0.1243386
# confidence intervals
table(Doff.by.quarter.2$PERCENT03_N > PER.MAC.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 1133 757
prop.table(table(Doff.by.quarter.2$PERCENT03_N > PER.MAC.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.5994709 0.4005291
table(Doff.by.quarter.2$PERCENT03_N > PER.MAC.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 1751 139
prop.table(table(Doff.by.quarter.2$PERCENT03_N >PER.MAC.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.92645503 0.07354497
# Set a seed for reproducibility
set.seed(123)
# IMI cow referent
# SCC IMI cow
SCC.IMI <- cutpointr(Pc.by.cow.C3, log.SCC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(SCC.IMI)
## Method: maximize_metric
## Predictor: log.SCC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4822 425 114 311
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.6151 1.0318 0.4541 0.6491 0.3826 0.2782 0.7484 74
## fn fp tn
## 40 192 119
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 2.833213 3.610918 4.356709 4.875197 5.006120 5.420535 7.305560
## 0 3.258097 3.465736 4.314000 4.908910 4.905444 5.316837 6.212545
## 1 2.833213 3.676221 4.375737 4.875197 5.043024 5.457180 7.536019
## Max. SD NAs
## 8.253228 1.0056560 0
## 7.658228 0.8688883 0
## 8.253228 1.0502220 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.26 3.26 4.50 4.62 Inf 4.97 5.43 Inf NaN 0
## AUC_b 0.37 0.43 0.46 0.48 0.48 0.50 0.53 0.59 0.03 0
## AUC_oob 0.35 0.41 0.45 0.48 0.48 0.51 0.55 0.63 0.04 0
## sum_sens_spec_b 0.98 1.01 1.03 1.06 1.06 1.09 1.14 1.22 0.04 0
## sum_sens_spec_oob 0.70 0.86 0.92 0.97 0.96 1.01 1.05 1.14 0.06 0
## acc_b 0.21 0.27 0.43 0.48 0.47 0.55 0.63 0.77 0.11 0
## acc_oob 0.16 0.26 0.37 0.45 0.43 0.50 0.57 0.77 0.10 0
## sensitivity_b 0.00 0.33 0.52 0.67 0.67 0.76 1.00 1.00 0.21 0
## sensitivity_oob 0.00 0.21 0.42 0.57 0.59 0.71 1.00 1.00 0.24 0
## specificity_b 0.00 0.01 0.32 0.41 0.40 0.56 0.74 1.00 0.23 0
## specificity_oob 0.00 0.01 0.28 0.39 0.37 0.53 0.70 1.00 0.22 0
## cohens_kappa_b -0.02 0.01 0.02 0.04 0.05 0.07 0.11 0.18 0.03 0
## cohens_kappa_oob -0.20 -0.11 -0.06 -0.02 -0.03 0.00 0.04 0.11 0.05 0
## ppv_b 0.20 0.25 0.27 0.29 0.29 0.31 0.35 0.42 0.03 2
## ppv_oob 0.00 0.18 0.23 0.25 0.25 0.28 0.31 0.38 0.04 2
## npv_b 0.68 0.72 0.75 0.77 0.81 0.81 1.00 1.00 0.09 0
## npv_oob 0.00 0.60 0.68 0.72 0.73 0.75 1.00 1.00 0.13 29
# ROC plot
plot(SCC.IMI)
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(SCC.IMI)
# NEU IMI cow
NEU.IMI <- cutpointr(Pc.by.cow.C3, log.TOTAL.NEU.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.IMI)
## Method: maximize_metric
## Predictor: log.TOTAL.NEU.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5446 427 312 115
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 4.5326 1.083 0.4543 0.3526 0.7304 0.7801 0.2937
## tp fn fp tn
## 110 202 31 84
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 2.197225 2.890372 3.569433 4.127134 4.266303 4.740565 6.127288
## 0 2.564949 2.855037 3.496048 4.077537 4.121409 4.614924 5.634352
## 1 2.197225 2.920109 3.583519 4.166635 4.319710 4.781216 6.235343
## Max. SD NAs
## 8.663369 1.0412536 0
## 7.411556 0.9043542 0
## 8.663369 1.0838380 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.77 3.33 3.96 4.53 4.39 4.84 5.47 7.85 0.70 0
## AUC_b 0.43 0.49 0.52 0.54 0.54 0.57 0.59 0.68 0.03 0
## AUC_oob 0.40 0.48 0.52 0.54 0.55 0.57 0.61 0.69 0.04 0
## sum_sens_spec_b 1.02 1.06 1.09 1.12 1.12 1.14 1.19 1.32 0.04 0
## sum_sens_spec_oob 0.77 0.91 0.97 1.01 1.01 1.05 1.10 1.23 0.06 0
## acc_b 0.25 0.35 0.41 0.49 0.51 0.60 0.71 0.77 0.12 0
## acc_oob 0.20 0.31 0.37 0.45 0.47 0.55 0.68 0.75 0.12 0
## sensitivity_b 0.02 0.13 0.25 0.39 0.46 0.63 0.88 0.99 0.26 0
## sensitivity_oob 0.00 0.11 0.21 0.36 0.43 0.60 0.87 0.98 0.26 0
## specificity_b 0.06 0.22 0.50 0.74 0.66 0.88 0.96 1.00 0.25 0
## specificity_oob 0.00 0.13 0.36 0.64 0.58 0.80 0.94 1.00 0.27 0
## cohens_kappa_b 0.01 0.04 0.06 0.09 0.09 0.12 0.16 0.25 0.04 0
## cohens_kappa_oob -0.18 -0.08 -0.02 0.01 0.01 0.03 0.07 0.18 0.05 0
## ppv_b 0.69 0.74 0.77 0.80 0.81 0.85 0.91 1.00 0.05 0
## ppv_oob 0.52 0.67 0.71 0.74 0.75 0.78 0.87 1.00 0.06 2
## npv_b 0.22 0.27 0.29 0.32 0.33 0.35 0.44 0.82 0.05 0
## npv_oob 0.00 0.20 0.25 0.27 0.27 0.30 0.34 0.50 0.04 0
# ROC plot
plot(NEU.IMI)
# Youden index plot
plot_metric(NEU.IMI)
# %NEU IMI cow
PER.NEU.IMI <- cutpointr(Pc.by.cow.C3, PERCENT.NEU.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.IMI)
## Method: maximize_metric
## Predictor: PERCENT.NEU.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5584 427 312 115
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 60.4 1.1229 0.5035 0.4359 0.687 0.7907 0.3098
## tp fn fp tn
## 136 176 36 79
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 21.23 36.928 48.7900 57.41 56.97274 65.370 75.682 86.98 11.78689 0
## 0 24.42 36.453 46.7650 55.42 55.29061 62.955 75.129 81.86 12.02568 0
## 1 21.23 37.723 49.6975 58.11 57.59276 65.850 75.805 86.98 11.65595 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 38.36 45.87 54.19 57.60 56.89 60.69 64.38 77.78 5.83
## AUC_b 0.45 0.51 0.54 0.56 0.56 0.58 0.61 0.67 0.03
## AUC_oob 0.39 0.49 0.53 0.56 0.56 0.59 0.62 0.71 0.04
## sum_sens_spec_b 0.91 1.08 1.12 1.15 1.15 1.18 1.23 1.29 0.05
## sum_sens_spec_oob 0.79 0.95 1.01 1.05 1.05 1.10 1.16 1.26 0.06
## acc_b 0.27 0.45 0.50 0.56 0.57 0.63 0.70 0.77 0.08
## acc_oob 0.26 0.41 0.47 0.52 0.53 0.58 0.67 0.74 0.08
## sensitivity_b 0.03 0.33 0.42 0.53 0.55 0.68 0.84 0.96 0.17
## sensitivity_oob 0.01 0.29 0.39 0.49 0.53 0.65 0.82 0.97 0.17
## specificity_b 0.08 0.30 0.47 0.64 0.60 0.74 0.82 1.00 0.17
## specificity_oob 0.03 0.21 0.38 0.56 0.53 0.69 0.78 1.00 0.19
## cohens_kappa_b -0.05 0.06 0.09 0.12 0.12 0.15 0.19 0.28 0.04
## cohens_kappa_oob -0.17 -0.04 0.01 0.04 0.04 0.08 0.13 0.22 0.05
## ppv_b 0.59 0.74 0.77 0.79 0.79 0.82 0.85 1.00 0.03
## ppv_oob 0.50 0.69 0.73 0.75 0.76 0.78 0.82 1.00 0.04
## npv_b 0.23 0.28 0.31 0.34 0.34 0.37 0.43 0.60 0.05
## npv_oob 0.10 0.22 0.26 0.29 0.29 0.32 0.37 0.50 0.05
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.IMI)
# Youden index plot
plot_metric(PER.NEU.IMI)
# LYM IMI cow
LYM.IMI <- cutpointr(Pc.by.cow.C3, log.TOTAL.LYM.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.IMI)
## Method: maximize_metric
## Predictor: log.TOTAL.LYM.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4718 427 115 312
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.091 1.0281 0.5105 0.5217 0.5064 0.2804 0.7418 60
## fn fp tn
## 55 154 158
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.791759 2.484907 3.091042 3.161188 3.610918 4.953707
## 0 0.000000 1.609438 2.397895 3.091042 3.041403 3.526361 4.409734
## 1 1.098612 1.945910 2.564949 3.044522 3.205340 3.637586 4.993262
## Max. SD NAs
## 6.921658 0.9859764 0
## 6.556778 0.9596418 0
## 6.921658 0.9933758 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 1.61 2.71 3.09 3.26 Inf 3.50 Inf Inf NaN 0
## AUC_b 0.36 0.42 0.45 0.47 0.47 0.49 0.52 0.58 0.03 0
## AUC_oob 0.33 0.41 0.44 0.47 0.47 0.50 0.54 0.66 0.04 0
## sum_sens_spec_b 0.98 1.00 1.02 1.05 1.05 1.08 1.13 1.19 0.04 0
## sum_sens_spec_oob 0.73 0.85 0.93 0.98 0.97 1.00 1.06 1.18 0.06 0
## acc_b 0.22 0.42 0.53 0.56 0.58 0.62 0.74 0.79 0.10 0
## acc_oob 0.22 0.36 0.49 0.52 0.54 0.58 0.74 0.81 0.11 0
## sensitivity_b 0.00 0.00 0.35 0.48 0.42 0.55 0.74 1.00 0.24 0
## sensitivity_oob 0.00 0.00 0.22 0.41 0.35 0.49 0.64 0.98 0.22 0
## specificity_b 0.01 0.32 0.52 0.59 0.64 0.71 1.00 1.00 0.22 0
## specificity_oob 0.00 0.28 0.50 0.56 0.61 0.68 1.00 1.00 0.23 0
## cohens_kappa_b -0.02 0.00 0.02 0.04 0.04 0.07 0.11 0.16 0.03 0
## cohens_kappa_oob -0.22 -0.12 -0.06 -0.02 -0.03 0.00 0.05 0.13 0.05 0
## ppv_b 0.22 0.25 0.28 0.30 0.34 0.33 0.67 1.00 0.16 132
## ppv_oob 0.00 0.00 0.22 0.25 0.23 0.28 0.32 0.39 0.08 249
## npv_b 0.67 0.71 0.73 0.75 0.75 0.77 0.80 1.00 0.04 0
## npv_oob 0.00 0.62 0.69 0.72 0.71 0.74 0.78 0.85 0.08 0
# ROC plot
plot(LYM.IMI)
## Warning: Removed 132 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(LYM.IMI)
# %LYM IMI cow
PER.LYM.IMI <- cutpointr(Pc.by.cow.C3, PERCENT.LYM.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.IMI)
## Method: maximize_metric
## Predictor: PERCENT.LYM.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4985 427 115 312
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 13.13 1.0559 0.3583 0.8957 0.1603 0.2822 0.8065
## tp fn fp tn
## 103 12 262 50
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 5.08 10.1460 15.675 19.20 19.32700 22.7400 29.383 51.10 5.899042 0
## 0 5.71 9.7530 16.155 19.30 19.23061 22.3750 28.473 35.94 5.629593 0
## 1 5.08 10.5395 15.520 19.19 19.36253 22.8475 29.465 51.10 6.003713 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 5.71 12.38 13.68 16.14 17.23 18.29 27.00 35.94 4.48
## AUC_b 0.40 0.45 0.48 0.50 0.50 0.52 0.55 0.59 0.03
## AUC_oob 0.34 0.43 0.47 0.50 0.50 0.53 0.57 0.66 0.04
## sum_sens_spec_b 0.93 1.02 1.06 1.08 1.08 1.11 1.15 1.23 0.04
## sum_sens_spec_oob 0.78 0.89 0.95 1.00 0.99 1.04 1.09 1.19 0.06
## acc_b 0.24 0.34 0.38 0.45 0.47 0.52 0.71 0.79 0.11
## acc_oob 0.18 0.31 0.36 0.41 0.44 0.48 0.68 0.76 0.11
## sensitivity_b 0.02 0.13 0.61 0.76 0.69 0.88 0.93 1.00 0.24
## sensitivity_oob 0.00 0.07 0.51 0.69 0.62 0.84 0.92 1.00 0.26
## specificity_b 0.00 0.14 0.19 0.32 0.39 0.48 0.92 0.99 0.24
## specificity_oob 0.00 0.12 0.17 0.30 0.37 0.45 0.91 0.98 0.24
## cohens_kappa_b -0.05 0.02 0.04 0.06 0.06 0.08 0.11 0.19 0.03
## cohens_kappa_oob -0.20 -0.10 -0.04 0.00 -0.01 0.02 0.06 0.12 0.05
## ppv_b 0.21 0.25 0.28 0.30 0.31 0.32 0.39 0.67 0.05
## ppv_oob 0.00 0.18 0.24 0.26 0.26 0.29 0.32 0.50 0.05
## npv_b 0.66 0.73 0.76 0.79 0.80 0.82 0.88 1.00 0.05
## npv_oob 0.00 0.65 0.70 0.73 0.73 0.77 0.85 1.00 0.07
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 5
# ROC plot
plot(PER.LYM.IMI)
# Youden index plot
plot_metric(PER.LYM.IMI)
# MAC IMI cow
MAC.IMI <- cutpointr(Pc.by.cow.C3, log.TOTAL.MAC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.IMI)
## Method: maximize_metric
## Predictor: log.TOTAL.MAC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4982 427 115 312
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.0445 1.0313 0.4848 0.5826 0.4487 0.2803 0.7447 67
## fn fp tn
## 48 172 140
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.791759 2.564949 3.178054 3.286585 3.871201 5.385332
## 0 1.098612 1.899665 2.602003 3.178054 3.244394 3.860674 4.598808
## 1 0.000000 1.609438 2.564949 3.135494 3.302136 3.871201 5.459102
## Max. SD NAs
## 8.318254 1.124299 0
## 7.097549 0.960287 0
## 8.318254 1.180058 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 1.10 1.79 2.20 3.04 Inf 3.64 4.13 Inf NaN 0
## AUC_b 0.40 0.45 0.48 0.50 0.50 0.52 0.55 0.61 0.03 0
## AUC_oob 0.37 0.43 0.47 0.50 0.50 0.53 0.57 0.63 0.04 0
## sum_sens_spec_b 0.95 1.02 1.05 1.07 1.07 1.09 1.14 1.25 0.04 0
## sum_sens_spec_oob 0.75 0.87 0.93 0.97 0.97 1.01 1.05 1.15 0.06 0
## acc_b 0.25 0.29 0.36 0.49 0.48 0.60 0.68 0.78 0.13 0
## acc_oob 0.21 0.27 0.33 0.44 0.44 0.54 0.65 0.78 0.12 0
## sensitivity_b 0.00 0.22 0.41 0.65 0.65 0.91 0.99 1.00 0.27 0
## sensitivity_oob 0.00 0.13 0.30 0.57 0.58 0.85 0.98 1.00 0.29 0
## specificity_b 0.00 0.05 0.15 0.45 0.42 0.67 0.84 1.00 0.27 0
## specificity_oob 0.00 0.03 0.13 0.40 0.39 0.64 0.82 1.00 0.27 0
## cohens_kappa_b -0.04 0.01 0.03 0.05 0.06 0.08 0.12 0.19 0.03 0
## cohens_kappa_oob -0.23 -0.11 -0.05 -0.02 -0.03 0.01 0.03 0.14 0.05 0
## ppv_b 0.20 0.25 0.28 0.30 0.30 0.32 0.37 1.00 0.04 2
## ppv_oob 0.00 0.17 0.23 0.26 0.25 0.28 0.31 0.38 0.05 3
## npv_b 0.63 0.72 0.75 0.78 0.80 0.83 0.94 1.00 0.07 0
## npv_oob 0.29 0.62 0.68 0.72 0.72 0.75 0.86 1.00 0.08 6
# ROC plot
plot(MAC.IMI)
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(MAC.IMI)
# %MAC IMI cow
PER.MAC.IMI<- cutpointr(Pc.by.cow.C3, PERCENT.MAC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.IMI)
## Method: maximize_metric
## Predictor: PERCENT.MAC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5549 427 115 312
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 36.61 1.1075 0.7049 0.2261 0.8814 0.4127 0.7555 26
## fn fp tn
## 89 37 275
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 3.51 8.640 15.1500 21.96 23.69944 30.7300 44.7900 73.11 11.55920 0
## 0 6.06 8.602 16.7250 23.42 25.47730 34.4400 46.0650 59.41 12.33271 0
## 1 3.51 8.640 14.9075 21.56 23.04413 29.9475 42.3765 73.11 11.21031 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 7.72 14.95 24.10 27.78 28.57 36.61 38.24 59.12 7.23
## AUC_b 0.44 0.50 0.53 0.56 0.56 0.58 0.61 0.65 0.03
## AUC_oob 0.41 0.49 0.53 0.55 0.55 0.58 0.62 0.70 0.04
## sum_sens_spec_b 1.03 1.08 1.11 1.14 1.14 1.17 1.21 1.29 0.04
## sum_sens_spec_oob 0.79 0.94 1.00 1.04 1.04 1.08 1.14 1.28 0.06
## acc_b 0.28 0.43 0.59 0.65 0.63 0.70 0.74 0.78 0.09
## acc_oob 0.25 0.38 0.54 0.60 0.59 0.67 0.72 0.80 0.10
## sensitivity_b 0.03 0.20 0.28 0.42 0.44 0.55 0.84 0.99 0.19
## sensitivity_oob 0.00 0.12 0.22 0.33 0.36 0.47 0.75 0.98 0.18
## specificity_b 0.05 0.28 0.61 0.72 0.70 0.86 0.91 1.00 0.19
## specificity_oob 0.01 0.25 0.57 0.70 0.68 0.85 0.91 1.00 0.19
## cohens_kappa_b 0.02 0.06 0.10 0.14 0.14 0.17 0.21 0.29 0.05
## cohens_kappa_oob -0.16 -0.05 0.00 0.04 0.04 0.08 0.14 0.33 0.06
## ppv_b 0.23 0.29 0.33 0.37 0.38 0.42 0.52 0.80 0.07
## ppv_oob 0.00 0.21 0.26 0.30 0.31 0.34 0.44 0.65 0.07
## npv_b 0.69 0.73 0.76 0.77 0.78 0.79 0.83 0.95 0.03
## npv_oob 0.50 0.68 0.72 0.74 0.74 0.77 0.80 0.87 0.04
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 1
## 0
## 0
# ROC plot
plot(PER.MAC.IMI)
# Youden index plot
plot_metric(PER.MAC.IMI)
# Summary of results when using C3 and cow-level IMI as reference
print(c("Optimal SCC:", exp(SCC.IMI$optimal_cutpoint), SCC.IMI$sensitivity, SCC.IMI$specificity, SCC.IMI$ppv, SCC.IMI$npv, SCC.IMI$AUC))
## sensitivity specificity
## "Optimal SCC:" "101" "0.649122807017544" "0.382636655948553"
##
## "0.278195488721804" "0.748427672955975" "0.482230495853782"
print(c("Optimal n NEU:", exp(NEU.IMI$optimal_cutpoint), NEU.IMI$sensitivity, NEU.IMI$specificity, NEU.IMI$ppv, NEU.IMI$npv, NEU.IMI$AUC))
## sensitivity specificity
## "Optimal n NEU:" "93" "0.352564102564103" "0.730434782608696"
##
## "0.780141843971631" "0.293706293706294" "0.544648829431438"
print(c("Optimal %NEU:", PER.NEU.IMI$optimal_cutpoint, PER.NEU.IMI$sensitivity, PER.NEU.IMI$specificity, PER.NEU.IMI$ppv, PER.NEU.IMI$npv, PER.NEU.IMI$AUC))
## sensitivity specificity
## "Optimal %NEU:" "60.4" "0.435897435897436" "0.68695652173913"
##
## "0.790697674418605" "0.309803921568627" "0.558389074693422"
print(c("Optimal n LYM:", exp(LYM.IMI$optimal_cutpoint), LYM.IMI$sensitivity, LYM.IMI$specificity, LYM.IMI$ppv, LYM.IMI$npv, LYM.IMI$AUC))
## sensitivity specificity
## "Optimal n LYM:" "22" "0.521739130434783" "0.506410256410256"
##
## "0.280373831775701" "0.741784037558685" "0.471794871794872"
print(c("Optimal %LYM:", PER.LYM.IMI$optimal_cutpoint, PER.LYM.IMI$sensitivity, PER.LYM.IMI$specificity, PER.LYM.IMI$ppv, PER.LYM.IMI$npv, PER.LYM.IMI$AUC))
## sensitivity specificity
## "Optimal %LYM:" "13.13" "0.895652173913044" "0.16025641025641"
##
## "0.282191780821918" "0.806451612903226" "0.498508918617614"
print(c("Optimal n MAC:", exp(MAC.IMI$optimal_cutpoint), MAC.IMI$sensitivity, MAC.IMI$specificity, MAC.IMI$ppv, MAC.IMI$npv, MAC.IMI$AUC))
## sensitivity specificity
## "Optimal n MAC:" "21" "0.582608695652174" "0.448717948717949"
##
## "0.280334728033473" "0.74468085106383" "0.498202341137124"
print(c("Optimal %MAC:", PER.MAC.IMI$optimal_cutpoint, PER.MAC.IMI$sensitivity, PER.MAC.IMI$specificity, PER.MAC.IMI$ppv, PER.MAC.IMI$npv, PER.MAC.IMI$AUC))
## sensitivity specificity
## "Optimal %MAC:" "36.61" "0.226086956521739" "0.881410256410256"
##
## "0.412698412698413" "0.755494505494505" "0.554877369007804"
# CI using bootstrapping
# SCC.IMI
SCC.IMI_optimal_cutpoint <- boot_ci(SCC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
SCC.IMI_lower_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(SCC.IMI_lower_ci)
## [1] 26
SCC.IMI_upper_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(SCC.IMI_upper_ci)
## [1] 246
boot_ci(SCC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.268
## 2 0.975 1
boot_ci(SCC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.00974
## 2 0.975 0.791
boot_ci(SCC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.238
## 2 0.975 0.354
boot_ci(SCC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.715
## 2 0.975 1
boot_ci(SCC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.422
## 2 0.975 0.546
# NEU.IMI
NEU.IMI_optimal_cutpoint <- boot_ci(NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.IMI_lower_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.IMI_lower_ci)
## [1] 25
NEU.IMI_upper_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.IMI_upper_ci)
## [1] 237
boot_ci(NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.116
## 2 0.975 0.900
boot_ci(NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.198
## 2 0.975 0.972
boot_ci(NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.731
## 2 0.975 0.927
boot_ci(NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.258
## 2 0.975 0.469
boot_ci(NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.482
## 2 0.975 0.602
# PER.NEU.IMI
PER.NEU.IMI_optimal_cutpoint <- boot_ci(PER.NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 45.8
## 2 0.975 64.4
PER.NEU.IMI_lower_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.IMI_upper_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.310
## 2 0.975 0.864
boot_ci(PER.NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.250
## 2 0.975 0.838
boot_ci(PER.NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.734
## 2 0.975 0.861
boot_ci(PER.NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.269
## 2 0.975 0.452
boot_ci(PER.NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.497
## 2 0.975 0.620
# LYM.IMI
LYM.IMI_optimal_cutpoint <- boot_ci(LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.IMI_lower_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.IMI_lower_ci)
## [1] 9
LYM.IMI_upper_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.IMI_upper_ci)
## [1] Inf
boot_ci(LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0
## 2 0.975 0.930
boot_ci(LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.104
## 2 0.975 1
boot_ci(LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.246
## 2 0.975 1
boot_ci(LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.704
## 2 0.975 0.818
boot_ci(LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.407
## 2 0.975 0.530
# PER.LYM.IMI
PER.LYM.IMI_optimal_cutpoint <- boot_ci(PER.LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 12.4
## 2 0.975 27.4
PER.LYM.IMI_lower_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.IMI_upper_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.106
## 2 0.975 0.945
boot_ci(PER.LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.130
## 2 0.975 0.940
boot_ci(PER.LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.248
## 2 0.975 0.431
boot_ci(PER.LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.718
## 2 0.975 0.896
boot_ci(PER.LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.434
## 2 0.975 0.557
# MAC.IMI
MAC.IMI_optimal_cutpoint <- boot_ci(MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.IMI_lower_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.IMI_lower_ci)
## [1] 4
MAC.IMI_upper_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.IMI_upper_ci)
## [1] 64
boot_ci(MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.2
## 2 0.975 1
boot_ci(MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0302
## 2 0.975 0.857
boot_ci(MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.245
## 2 0.975 0.395
boot_ci(MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.713
## 2 0.975 1
boot_ci(MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.437
## 2 0.975 0.558
# PER.MAC.IMI
PER.MAC.IMI_optimal_cutpoint <- boot_ci(PER.MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 13.4
## 2 0.975 38.3
PER.MAC.IMI_lower_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.IMI_upper_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.178
## 2 0.975 0.878
boot_ci(PER.MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.236
## 2 0.975 0.929
boot_ci(PER.MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.277
## 2 0.975 0.537
boot_ci(PER.MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.724
## 2 0.975 0.849
boot_ci(PER.MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.492
## 2 0.975 0.617
# Prevalence
# True prevalence
table(Pc.by.cow.C3$IMI.cow)
##
## 0 1
## 115 313
prop.table(table(Pc.by.cow.C3$IMI.cow))
##
## 0 1
## 0.2686916 0.7313084
#Apparent prevalence
# ---- SCC ----
# optimal cut-off
optimal_scc_C3_IMI_cow <- SCC.IMI$optimal_cutpoint
table(Pc.by.cow.C3$SCC.CO.COW > exp(optimal_scc_C3_IMI_cow))
##
## FALSE TRUE
## 161 267
prop.table(table(Pc.by.cow.C3$SCC.CO.COW > exp(optimal_scc_C3_IMI_cow)))
##
## FALSE TRUE
## 0.3761682 0.6238318
# confidence intervals
table(Pc.by.cow.C3$SCC.CO.COW > exp(SCC.IMI_lower_ci))
##
## FALSE TRUE
## 6 422
prop.table(table(Pc.by.cow.C3$SCC.CO.COW > exp(SCC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.01401869 0.98598131
table(Pc.by.cow.C3$SCC.CO.COW > exp(SCC.IMI_upper_ci))
##
## FALSE TRUE
## 328 100
prop.table(table(Pc.by.cow.C3$SCC.CO.COW >exp(SCC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.7663551 0.2336449
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C3_IMI_cow <- NEU.IMI$optimal_cutpoint
table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(optimal_neu_C3_IMI_cow))
##
## FALSE TRUE
## 290 140
prop.table(table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(optimal_neu_C3_IMI_cow)))
##
## FALSE TRUE
## 0.6744186 0.3255814
# confidence intervals
table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(NEU.IMI_lower_ci))
##
## FALSE TRUE
## 54 376
prop.table(table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(NEU.IMI_lower_ci)))
##
## FALSE TRUE
## 0.1255814 0.8744186
table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(NEU.IMI_upper_ci))
##
## FALSE TRUE
## 387 43
prop.table(table(Pc.by.cow.C3$TOTAL.NEU.CO.COW >exp(NEU.IMI_upper_ci)))
##
## FALSE TRUE
## 0.9 0.1
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C3_IMI_cow <-PER.NEU.IMI$optimal_cutpoint
table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > optimal_per_neu_C3_IMI_cow)
##
## FALSE TRUE
## 259 171
prop.table(table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > optimal_per_neu_C3_IMI_cow))
##
## FALSE TRUE
## 0.6023256 0.3976744
# confidence intervals
table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > PER.NEU.IMI_lower_ci)
##
## FALSE TRUE
## 81 349
prop.table(table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > PER.NEU.IMI_lower_ci))
##
## FALSE TRUE
## 0.1883721 0.8116279
table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > PER.NEU.IMI_upper_ci)
##
## FALSE TRUE
## 306 124
prop.table(table(Pc.by.cow.C3$PERCENT.NEU.CO.COW >PER.NEU.IMI_upper_ci))
##
## FALSE TRUE
## 0.7116279 0.2883721
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C3_IMI_cow <-LYM.IMI$optimal_cutpoint
table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(optimal_lym_C3_IMI_cow))
##
## FALSE TRUE
## 226 204
prop.table(table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(optimal_lym_C3_IMI_cow)))
##
## FALSE TRUE
## 0.5255814 0.4744186
# confidence intervals
table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(LYM.IMI_lower_ci))
##
## FALSE TRUE
## 66 364
prop.table(table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(LYM.IMI_lower_ci)))
##
## FALSE TRUE
## 0.1534884 0.8465116
table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(LYM.IMI_upper_ci))
##
## FALSE
## 430
prop.table(table(Pc.by.cow.C3$TOTAL.LYM.CO.COW >exp(LYM.IMI_upper_ci)))
##
## FALSE
## 1
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C3_IMI_cow <-PER.LYM.IMI$optimal_cutpoint
table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > optimal_per_lym_C3_IMI_cow)
##
## FALSE TRUE
## 63 367
prop.table(table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > optimal_per_lym_C3_IMI_cow))
##
## FALSE TRUE
## 0.1465116 0.8534884
# confidence intervals
table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > PER.LYM.IMI_lower_ci)
##
## FALSE TRUE
## 58 372
prop.table(table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > PER.LYM.IMI_lower_ci))
##
## FALSE TRUE
## 0.1348837 0.8651163
table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > PER.LYM.IMI_upper_ci)
##
## FALSE TRUE
## 394 36
prop.table(table(Pc.by.cow.C3$PERCENT.LYM.CO.COW >PER.LYM.IMI_upper_ci))
##
## FALSE TRUE
## 0.91627907 0.08372093
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C3_IMI_cow <- MAC.IMI$optimal_cutpoint
table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(optimal_mac_C3_IMI_cow))
##
## FALSE TRUE
## 200 230
prop.table(table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(optimal_mac_C3_IMI_cow)))
##
## FALSE TRUE
## 0.4651163 0.5348837
# confidence intervals
table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(MAC.IMI_lower_ci))
##
## FALSE TRUE
## 12 418
prop.table(table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(MAC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.02790698 0.97209302
table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(MAC.IMI_upper_ci))
##
## FALSE TRUE
## 355 75
prop.table(table(Pc.by.cow.C3$TOTAL.MAC.CO.COW >exp(MAC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.8255814 0.1744186
# Percent MAC
# optimal cut-off
optimal_per_mac_C3_IMI_cow <- PER.MAC.IMI$optimal_cutpoint
table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > optimal_per_mac_C3_IMI_cow)
##
## FALSE TRUE
## 368 62
prop.table(table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > optimal_per_mac_C3_IMI_cow))
##
## FALSE TRUE
## 0.855814 0.144186
# confidence intervals
table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > PER.MAC.IMI_lower_ci)
##
## FALSE TRUE
## 91 339
prop.table(table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > PER.MAC.IMI_lower_ci))
##
## FALSE TRUE
## 0.2116279 0.7883721
table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > PER.MAC.IMI_upper_ci)
##
## FALSE TRUE
## 379 51
prop.table(table(Pc.by.cow.C3$PERCENT.MAC.CO.COW >PER.MAC.IMI_upper_ci))
##
## FALSE TRUE
## 0.8813953 0.1186047
# Set a seed for reproducibility
set.seed(123)
# Delaval SCM (SCC>200.000) reference
# n NEU SCM COW
NEU.SCM <- cutpointr(Pc.by.cow.C3, log.TOTAL.NEU.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.NEU.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9021 428 118 310
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.6347 1.6466 0.8505 0.7627 0.8839 0.7143 0.9073 90
## fn fp tn
## 28 36 274
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 2.197225 2.890372 3.583519 4.127134 4.267632 4.738382 6.126631
## 0 2.197225 2.833213 3.433987 3.871201 3.858973 4.304065 4.895162
## 1 3.367296 4.001777 4.637144 5.043404 5.341228 5.973170 7.852476
## Max. SD NAs
## 8.663369 1.0386410 0
## 5.934894 0.6462305 0
## 8.663369 1.1086912 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 4.17 4.17 4.42 4.43 4.48 4.63 4.64 4.82 0.17 0
## AUC_b 0.84 0.87 0.89 0.90 0.90 0.91 0.93 0.94 0.02 0
## AUC_oob 0.83 0.87 0.89 0.90 0.90 0.92 0.94 0.96 0.02 0
## sum_sens_spec_b 1.55 1.60 1.64 1.66 1.66 1.68 1.72 1.78 0.04 0
## sum_sens_spec_oob 1.41 1.52 1.57 1.61 1.61 1.65 1.70 1.79 0.06 0
## acc_b 0.72 0.76 0.80 0.83 0.83 0.86 0.88 0.90 0.04 0
## acc_oob 0.67 0.73 0.78 0.82 0.81 0.84 0.87 0.91 0.04 0
## sensitivity_b 0.66 0.74 0.78 0.83 0.83 0.88 0.95 0.98 0.07 0
## sensitivity_oob 0.51 0.67 0.73 0.80 0.80 0.86 0.93 1.00 0.08 0
## specificity_b 0.64 0.70 0.78 0.84 0.83 0.88 0.91 0.95 0.07 0
## specificity_oob 0.56 0.67 0.76 0.83 0.81 0.88 0.92 0.96 0.08 0
## cohens_kappa_b 0.43 0.50 0.57 0.61 0.61 0.65 0.70 0.76 0.06 0
## cohens_kappa_oob 0.33 0.45 0.51 0.57 0.56 0.62 0.68 0.76 0.07 0
## ppv_b 0.46 0.53 0.60 0.66 0.66 0.72 0.78 0.87 0.08 0
## ppv_oob 0.38 0.49 0.57 0.64 0.64 0.70 0.78 0.87 0.09 0
## npv_b 0.85 0.89 0.91 0.93 0.93 0.95 0.97 0.99 0.02 0
## npv_oob 0.81 0.87 0.90 0.92 0.92 0.94 0.97 1.00 0.03 0
# ROC plot
plot(NEU.SCM)
# Youden index plot
plot_metric(NEU.SCM)
# %NEU SCM COW
PER.NEU.SCM <- cutpointr(Pc.by.cow.C3, PERCENT.NEU.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.SCM)
## Method: maximize_metric
## Predictor: PERCENT.NEU.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4771 428 118 310
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 58.26 1.0302 0.5257 0.4915 0.5387 0.2886 0.7357 58
## fn fp tn
## 60 143 167
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 21.23 36.9360 48.6575 57.405 56.93164 65.3600 75.669 86.98 11.78750
## 0 21.23 37.7180 49.1975 57.270 57.31045 65.2575 75.871 86.98 11.52648
## 1 24.42 34.5775 46.0125 57.675 55.93644 65.4875 75.012 81.00 12.44289
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 24.42 30.82 57.20 61.00 Inf 65.35 74.97 Inf NaN 0
## AUC_b 0.36 0.42 0.45 0.48 0.48 0.50 0.53 0.59 0.03 0
## AUC_oob 0.34 0.41 0.45 0.48 0.48 0.51 0.55 0.64 0.04 0
## sum_sens_spec_b 1.00 1.00 1.03 1.06 1.06 1.09 1.14 1.26 0.04 0
## sum_sens_spec_oob 0.74 0.87 0.93 0.97 0.97 1.00 1.06 1.16 0.06 0
## acc_b 0.23 0.29 0.53 0.58 0.56 0.63 0.70 0.77 0.11 0
## acc_oob 0.20 0.27 0.48 0.54 0.53 0.60 0.67 0.77 0.11 0
## sensitivity_b 0.00 0.09 0.31 0.44 0.46 0.56 1.00 1.00 0.23 0
## sensitivity_oob 0.00 0.04 0.23 0.36 0.39 0.49 0.97 1.00 0.23 0
## specificity_b 0.00 0.01 0.52 0.64 0.60 0.76 0.94 1.00 0.23 0
## specificity_oob 0.00 0.01 0.49 0.61 0.58 0.73 0.92 1.00 0.23 0
## cohens_kappa_b 0.00 0.00 0.03 0.05 0.06 0.08 0.13 0.20 0.04 0
## cohens_kappa_oob -0.20 -0.11 -0.06 -0.03 -0.03 0.00 0.05 0.14 0.05 0
## ppv_b 0.22 0.26 0.29 0.31 0.32 0.34 0.38 1.00 0.04 27
## ppv_oob 0.00 0.15 0.22 0.26 0.25 0.28 0.32 0.38 0.06 27
## npv_b 0.66 0.71 0.73 0.75 0.76 0.77 1.00 1.00 0.07 0
## npv_oob 0.00 0.50 0.68 0.71 0.69 0.74 0.77 1.00 0.10 63
# ROC plot
plot(PER.NEU.SCM)
## Warning: Removed 27 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(PER.NEU.SCM)
# Lym
LYM.SCM <- cutpointr(Pc.by.cow.C3, log.TOTAL.LYM.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.LYM.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9203 428 118 310
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.4012 1.7063 0.8481 0.8644 0.8419 0.6755 0.9422
## tp fn fp tn
## 102 16 49 261
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.845712 2.544939 3.067782 3.163271 3.610918 4.953354
## 0 0.000000 1.609438 2.302585 2.833213 2.762575 3.208670 3.715714
## 1 2.079442 2.995732 3.533607 4.034201 4.215948 4.755396 6.199995
## Max. SD NAs
## 6.921658 0.9821074 0
## 4.521789 0.6315192 0
## 6.921658 0.9611697 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.14 3.18 3.37 3.40 3.42 3.50 3.53 3.71 0.10 0
## AUC_b 0.86 0.89 0.91 0.92 0.92 0.93 0.95 0.97 0.02 0
## AUC_oob 0.85 0.88 0.91 0.92 0.92 0.93 0.95 0.98 0.02 0
## sum_sens_spec_b 1.59 1.66 1.70 1.72 1.72 1.74 1.78 1.84 0.04 0
## sum_sens_spec_oob 1.44 1.58 1.64 1.68 1.67 1.71 1.76 1.83 0.05 0
## acc_b 0.77 0.81 0.84 0.86 0.86 0.88 0.89 0.93 0.03 0
## acc_oob 0.71 0.79 0.82 0.84 0.84 0.86 0.88 0.92 0.03 0
## sensitivity_b 0.68 0.78 0.83 0.87 0.86 0.89 0.94 0.99 0.05 0
## sensitivity_oob 0.52 0.70 0.79 0.83 0.83 0.88 0.93 1.00 0.07 0
## specificity_b 0.69 0.76 0.83 0.86 0.86 0.89 0.92 0.97 0.04 0
## specificity_oob 0.65 0.74 0.82 0.85 0.84 0.88 0.92 0.98 0.05 0
## cohens_kappa_b 0.52 0.58 0.64 0.67 0.67 0.70 0.74 0.83 0.05 0
## cohens_kappa_oob 0.42 0.53 0.59 0.63 0.63 0.67 0.72 0.82 0.06 0
## ppv_b 0.52 0.59 0.66 0.70 0.70 0.74 0.80 0.91 0.06 0
## ppv_oob 0.45 0.56 0.63 0.68 0.68 0.72 0.79 0.92 0.07 0
## npv_b 0.88 0.91 0.93 0.94 0.94 0.96 0.97 1.00 0.02 0
## npv_oob 0.83 0.88 0.91 0.93 0.93 0.95 0.97 1.00 0.03 0
# ROC plot
plot(LYM.SCM)
# Youden index plot
plot_metric(LYM.SCM)
# %LYM SCM COW
PER.LYM.SCM <- cutpointr(Pc.by.cow.C3, PERCENT.LYM.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.SCM)
## Method: maximize_metric
## Predictor: PERCENT.LYM.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.571 428 310 118
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 22.45 1.1922 0.472 0.3194 0.8729 0.8684 0.328 99
## fn fp tn
## 211 15 103
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 5.08 10.147 15.6800 19.205 19.32189 22.6625 29.3785 51.1 5.879269 0
## 0 5.66 10.149 15.6750 19.525 19.69710 23.4225 29.5805 51.1 6.163532 0
## 1 5.08 11.199 15.7225 17.990 18.33619 21.0925 27.4830 36.5 4.946434 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 16.49 18.44 19.06 22.45 21.30 22.45 22.73 24.44 1.63
## AUC_b 0.48 0.52 0.55 0.57 0.57 0.59 0.62 0.65 0.03
## AUC_oob 0.44 0.51 0.55 0.57 0.57 0.60 0.64 0.71 0.04
## sum_sens_spec_b 1.06 1.14 1.18 1.21 1.21 1.23 1.27 1.33 0.04
## sum_sens_spec_oob 0.85 1.02 1.10 1.15 1.14 1.19 1.25 1.34 0.07
## acc_b 0.36 0.44 0.47 0.50 0.52 0.57 0.62 0.67 0.06
## acc_oob 0.33 0.41 0.45 0.48 0.49 0.52 0.58 0.65 0.05
## sensitivity_b 0.18 0.28 0.31 0.35 0.41 0.53 0.62 0.77 0.12
## sensitivity_oob 0.16 0.25 0.30 0.34 0.39 0.50 0.60 0.69 0.12
## specificity_b 0.43 0.59 0.69 0.85 0.80 0.89 0.92 0.97 0.12
## specificity_oob 0.22 0.48 0.61 0.82 0.75 0.88 0.92 1.00 0.15
## cohens_kappa_b 0.03 0.09 0.12 0.14 0.15 0.17 0.21 0.28 0.04
## cohens_kappa_oob -0.14 0.02 0.07 0.10 0.10 0.13 0.17 0.25 0.05
## ppv_b 0.72 0.78 0.82 0.85 0.85 0.88 0.92 0.97 0.04
## ppv_oob 0.66 0.72 0.77 0.82 0.82 0.87 0.92 1.00 0.06
## npv_b 0.25 0.29 0.32 0.34 0.34 0.36 0.40 0.45 0.03
## npv_oob 0.19 0.26 0.29 0.32 0.32 0.34 0.38 0.46 0.04
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.LYM.SCM)
# Youden index plot
plot_metric(PER.LYM.SCM)
# MAC SCM COW
MAC.SCM <- cutpointr(Pc.by.cow.C3, log.TOTAL.MAC.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.MAC.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9122 428 118 310
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.5835 1.666 0.8341 0.8305 0.8355 0.6577 0.9283 98
## fn fp tn
## 20 51 259
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.791759 2.564949 3.178054 3.291112 3.871201 5.383950
## 0 0.000000 1.609438 2.397895 2.833213 2.846021 3.392722 3.970292
## 1 2.833213 3.029510 3.719596 4.241301 4.460422 5.055237 6.696229
## Max. SD NAs
## 8.318254 1.121363 0
## 4.663439 0.742693 0
## 8.318254 1.108391 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.04 3.58 3.58 3.58 3.63 3.64 3.87 4.06 0.11 0
## AUC_b 0.86 0.89 0.90 0.91 0.91 0.92 0.93 0.96 0.01 0
## AUC_oob 0.84 0.88 0.90 0.91 0.91 0.93 0.94 0.97 0.02 0
## sum_sens_spec_b 1.53 1.61 1.64 1.67 1.67 1.70 1.73 1.82 0.04 0
## sum_sens_spec_oob 1.41 1.53 1.60 1.64 1.64 1.68 1.74 1.82 0.06 0
## acc_b 0.69 0.81 0.83 0.84 0.84 0.86 0.88 0.92 0.02 0
## acc_oob 0.67 0.79 0.82 0.83 0.83 0.85 0.87 0.91 0.02 0
## sensitivity_b 0.62 0.73 0.79 0.82 0.82 0.85 0.88 0.95 0.05 0
## sensitivity_oob 0.45 0.63 0.76 0.81 0.79 0.84 0.90 1.00 0.08 0
## specificity_b 0.60 0.80 0.83 0.85 0.85 0.87 0.93 0.99 0.04 0
## specificity_oob 0.56 0.78 0.82 0.84 0.85 0.87 0.93 1.00 0.04 0
## cohens_kappa_b 0.40 0.56 0.60 0.63 0.63 0.66 0.70 0.79 0.04 0
## cohens_kappa_oob 0.36 0.51 0.57 0.60 0.60 0.64 0.68 0.78 0.05 0
## ppv_b 0.45 0.61 0.65 0.68 0.69 0.71 0.80 0.96 0.06 0
## ppv_oob 0.43 0.57 0.62 0.66 0.67 0.70 0.79 1.00 0.07 0
## npv_b 0.85 0.89 0.91 0.93 0.92 0.94 0.95 0.97 0.02 0
## npv_oob 0.77 0.86 0.90 0.92 0.92 0.94 0.96 1.00 0.03 0
# ROC plot
plot(MAC.SCM)
# Youden index plot
plot_metric(MAC.SCM)
# %MAC SCM COW
PER.MAC.SCM <- cutpointr(Pc.by.cow.C3, PERCENT.MAC.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.SCM)
## Method: maximize_metric
## Predictor: PERCENT.MAC.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5656 428 118 310
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 23.3 1.1976 0.6051 0.5847 0.6129 0.3651 0.795 69
## fn fp tn
## 49 120 190
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 3.51 8.6400 15.2325 21.955 23.74565 30.8125 44.7650 73.11 11.55696 0
## 0 3.51 8.7075 15.1350 21.155 22.99168 29.8275 42.3935 73.11 11.10716 0
## 1 4.67 8.6385 15.6950 24.695 25.72644 33.3975 49.4035 59.41 12.49658 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 10.73 23.14 23.14 23.30 23.58 23.47 24.27 45.43 2.19
## AUC_b 0.44 0.51 0.54 0.56 0.56 0.59 0.62 0.68 0.03
## AUC_oob 0.42 0.49 0.54 0.57 0.57 0.60 0.64 0.72 0.04
## sum_sens_spec_b 1.02 1.12 1.17 1.20 1.20 1.24 1.29 1.39 0.05
## sum_sens_spec_oob 0.91 1.04 1.12 1.17 1.17 1.22 1.29 1.39 0.08
## acc_b 0.34 0.57 0.59 0.61 0.61 0.63 0.65 0.76 0.03
## acc_oob 0.32 0.54 0.58 0.60 0.60 0.62 0.65 0.72 0.04
## sensitivity_b 0.09 0.50 0.56 0.59 0.59 0.62 0.67 0.96 0.07
## sensitivity_oob 0.02 0.43 0.51 0.56 0.56 0.61 0.67 0.93 0.09
## specificity_b 0.14 0.56 0.59 0.62 0.62 0.64 0.67 0.96 0.06
## specificity_oob 0.10 0.54 0.58 0.61 0.61 0.64 0.68 0.96 0.07
## cohens_kappa_b 0.03 0.10 0.14 0.17 0.17 0.20 0.25 0.33 0.05
## cohens_kappa_oob -0.07 0.03 0.10 0.14 0.14 0.18 0.24 0.34 0.06
## ppv_b 0.25 0.31 0.35 0.37 0.37 0.39 0.43 0.68 0.04
## ppv_oob 0.17 0.27 0.32 0.35 0.35 0.38 0.43 0.56 0.05
## npv_b 0.70 0.75 0.78 0.80 0.80 0.81 0.84 0.94 0.03
## npv_oob 0.57 0.72 0.76 0.79 0.78 0.81 0.84 0.91 0.04
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.MAC.SCM)
# Youden index plot
plot_metric(PER.MAC.SCM)
# Summary of results when using SCM as reference
print(c("Optimal n NEU:", exp(NEU.SCM$optimal_cutpoint), NEU.SCM$sensitivity, NEU.SCM$specificity, NEU.SCM$ppv, NEU.SCM$npv, NEU.SCM$AUC))
## sensitivity specificity
## "Optimal n NEU:" "103" "0.76271186440678" "0.883870967741936"
##
## "0.714285714285714" "0.907284768211921" "0.902104975396391"
print(c("Optimal %NEU:", PER.NEU.SCM$optimal_cutpoint, PER.NEU.SCM$sensitivity, PER.NEU.SCM$specificity, PER.NEU.SCM$ppv, PER.NEU.SCM$npv, PER.NEU.SCM$AUC))
## sensitivity specificity
## "Optimal %NEU:" "58.26" "0.491525423728814" "0.538709677419355"
##
## "0.288557213930348" "0.73568281938326" "0.477104975396391"
print(c("Optimal n LYM:", exp(LYM.SCM$optimal_cutpoint), LYM.SCM$sensitivity, LYM.SCM$specificity, LYM.SCM$ppv, LYM.SCM$npv, LYM.SCM$AUC))
## sensitivity specificity
## "Optimal n LYM:" "30" "0.864406779661017" "0.841935483870968"
##
## "0.675496688741722" "0.942238267148014" "0.920270639693822"
print(c("Optimal %LYM:", PER.LYM.SCM$optimal_cutpoint, PER.LYM.SCM$sensitivity, PER.LYM.SCM$specificity, PER.LYM.SCM$ppv, PER.LYM.SCM$npv, PER.LYM.SCM$AUC))
## sensitivity specificity
## "Optimal %LYM:" "22.45" "0.319354838709677" "0.872881355932203"
##
## "0.868421052631579" "0.328025477707006" "0.570995079278294"
print(c("Optimal n MAC:", exp(MAC.SCM$optimal_cutpoint), MAC.SCM$sensitivity, MAC.SCM$specificity, MAC.SCM$ppv, MAC.SCM$npv, MAC.SCM$AUC))
## sensitivity specificity
## "Optimal n MAC:" "36" "0.830508474576271" "0.835483870967742"
##
## "0.657718120805369" "0.92831541218638" "0.912178786221979"
print(c("Optimal %MAC:", PER.MAC.SCM$optimal_cutpoint, PER.MAC.SCM$sensitivity, PER.MAC.SCM$specificity, PER.MAC.SCM$ppv, PER.MAC.SCM$npv, PER.MAC.SCM$AUC))
## sensitivity specificity
## "Optimal %MAC:" "23.3" "0.584745762711864" "0.612903225806452"
##
## "0.365079365079365" "0.794979079497908" "0.565554948059049"
# NEU.SCM
NEU.SCM_optimal_cutpoint <- boot_ci(NEU.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.SCM_lower_ci <- subset(NEU.SCM_optimal_cutpoint, NEU.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.SCM_lower_ci)
## [1] 65
NEU.SCM_upper_ci <- subset(NEU.SCM_optimal_cutpoint, NEU.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.SCM_upper_ci)
## [1] 106
boot_ci(NEU.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.722
## 2 0.975 0.958
boot_ci(NEU.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.683
## 2 0.975 0.917
boot_ci(NEU.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.510
## 2 0.975 0.793
boot_ci(NEU.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.888
## 2 0.975 0.978
boot_ci(NEU.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.870
## 2 0.975 0.931
# PER.NEU.SCM
PER.NEU.SCM_optimal_cutpoint <- boot_ci(PER.NEU.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 24.4
## 2 0.975 75.3
PER.NEU.SCM_lower_ci <- subset(PER.NEU.SCM_optimal_cutpoint, PER.NEU.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.SCM_upper_ci <- subset(PER.NEU.SCM_optimal_cutpoint, PER.NEU.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0588
## 2 0.975 1
boot_ci(PER.NEU.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.00627
## 2 0.975 0.962
boot_ci(PER.NEU.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.255
## 2 0.975 0.409
boot_ci(PER.NEU.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.699
## 2 0.975 1
boot_ci(PER.NEU.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.414
## 2 0.975 0.542
# LYM.SCM
LYM.SCM_optimal_cutpoint <- boot_ci(LYM.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.SCM_lower_ci <- subset(LYM.SCM_optimal_cutpoint, LYM.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.SCM_lower_ci)
## [1] 24
LYM.SCM_upper_ci <- subset(LYM.SCM_optimal_cutpoint, LYM.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.SCM_upper_ci)
## [1] 38
boot_ci(LYM.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.767
## 2 0.975 0.951
boot_ci(LYM.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.748
## 2 0.975 0.936
boot_ci(LYM.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.572
## 2 0.975 0.829
boot_ci(LYM.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.909
## 2 0.975 0.977
boot_ci(LYM.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.888
## 2 0.975 0.948
# PER.LYM.SCM
PER.LYM.SCM_optimal_cutpoint <- boot_ci(PER.LYM.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 18.4
## 2 0.975 23.3
PER.LYM.SCM_lower_ci <- subset(PER.LYM.SCM_optimal_cutpoint, PER.LYM.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.SCM_upper_ci <- subset(PER.LYM.SCM_optimal_cutpoint, PER.LYM.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.267
## 2 0.975 0.630
boot_ci(PER.LYM.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.565
## 2 0.975 0.930
boot_ci(PER.LYM.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.771
## 2 0.975 0.926
boot_ci(PER.LYM.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.284
## 2 0.975 0.405
boot_ci(PER.LYM.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.513
## 2 0.975 0.625
# MAC.SCM
MAC.SCM_optimal_cutpoint <- boot_ci(MAC.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.SCM_lower_ci <- subset(MAC.SCM_optimal_cutpoint, MAC.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.SCM_lower_ci)
## [1] 32
MAC.SCM_upper_ci <- subset(MAC.SCM_optimal_cutpoint, MAC.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.SCM_upper_ci)
## [1] 52
boot_ci(MAC.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.702
## 2 0.975 0.894
boot_ci(MAC.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.793
## 2 0.975 0.947
boot_ci(MAC.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.588
## 2 0.975 0.837
boot_ci(MAC.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.886
## 2 0.975 0.957
boot_ci(MAC.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.882
## 2 0.975 0.940
# PER.MAC.SCM
PER.MAC.SCM_optimal_cutpoint <- boot_ci(PER.MAC.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 22.0
## 2 0.975 26.6
PER.MAC.SCM_lower_ci <- subset(PER.MAC.SCM_optimal_cutpoint, PER.MAC.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.SCM_upper_ci <- subset(PER.MAC.SCM_optimal_cutpoint, PER.MAC.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.474
## 2 0.975 0.695
boot_ci(PER.MAC.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.543
## 2 0.975 0.692
boot_ci(PER.MAC.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.298
## 2 0.975 0.449
boot_ci(PER.MAC.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.744
## 2 0.975 0.848
boot_ci(PER.MAC.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.502
## 2 0.975 0.629
# Prevalence
# True prevalence
table(Pc.by.cow.C3$delaval.SCM.CO.COW)
##
## 0 1
## 310 118
prop.table(table(Pc.by.cow.C3$delaval.SCM.CO.COW))
##
## 0 1
## 0.7242991 0.2757009
#Apparent prevalence
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C3_SCM_cow <- NEU.SCM$optimal_cutpoint
table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(optimal_neu_C3_SCM_cow))
##
## FALSE TRUE
## 307 123
prop.table(table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(optimal_neu_C3_SCM_cow)))
##
## FALSE TRUE
## 0.7139535 0.2860465
# confidence intervals
table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(NEU.SCM_lower_ci))
##
## FALSE TRUE
## 223 207
prop.table(table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(NEU.SCM_lower_ci)))
##
## FALSE TRUE
## 0.5186047 0.4813953
table(Pc.by.cow.C3$TOTAL.NEU.CO.COW > exp(NEU.SCM_upper_ci))
##
## FALSE TRUE
## 309 121
prop.table(table(Pc.by.cow.C3$TOTAL.NEU.CO.COW >exp(NEU.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7186047 0.2813953
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C3_SCM_cow <-PER.NEU.SCM$optimal_cutpoint
table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > optimal_per_neu_C3_SCM_cow)
##
## FALSE TRUE
## 228 202
prop.table(table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > optimal_per_neu_C3_SCM_cow))
##
## FALSE TRUE
## 0.5302326 0.4697674
# confidence intervals
table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > PER.NEU.SCM_lower_ci)
##
## FALSE TRUE
## 2 428
prop.table(table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > PER.NEU.SCM_lower_ci))
##
## FALSE TRUE
## 0.004651163 0.995348837
table(Pc.by.cow.C3$PERCENT.NEU.CO.COW > PER.NEU.SCM_upper_ci)
##
## FALSE TRUE
## 406 24
prop.table(table(Pc.by.cow.C3$PERCENT.NEU.CO.COW >PER.NEU.SCM_upper_ci))
##
## FALSE TRUE
## 0.94418605 0.05581395
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C3_SCM_cow <-LYM.SCM$optimal_cutpoint
table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(optimal_lym_C3_SCM_cow))
##
## FALSE TRUE
## 284 146
prop.table(table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(optimal_lym_C3_SCM_cow)))
##
## FALSE TRUE
## 0.6604651 0.3395349
# confidence intervals
table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(LYM.SCM_lower_ci))
##
## FALSE TRUE
## 243 187
prop.table(table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(LYM.SCM_lower_ci)))
##
## FALSE TRUE
## 0.5651163 0.4348837
table(Pc.by.cow.C3$TOTAL.LYM.CO.COW > exp(LYM.SCM_upper_ci))
##
## FALSE TRUE
## 326 104
prop.table(table(Pc.by.cow.C3$TOTAL.LYM.CO.COW >exp(LYM.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7581395 0.2418605
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C3_SCM_cow <-PER.LYM.SCM$optimal_cutpoint
table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > optimal_per_lym_C3_SCM_cow)
##
## FALSE TRUE
## 317 113
prop.table(table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > optimal_per_lym_C3_SCM_cow))
##
## FALSE TRUE
## 0.7372093 0.2627907
# confidence intervals
table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > PER.LYM.SCM_lower_ci)
##
## FALSE TRUE
## 189 241
prop.table(table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > PER.LYM.SCM_lower_ci))
##
## FALSE TRUE
## 0.4395349 0.5604651
table(Pc.by.cow.C3$PERCENT.LYM.CO.COW > PER.LYM.SCM_upper_ci)
##
## FALSE TRUE
## 335 95
prop.table(table(Pc.by.cow.C3$PERCENT.LYM.CO.COW >PER.LYM.SCM_upper_ci))
##
## FALSE TRUE
## 0.7790698 0.2209302
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C3_SCM_cow <- MAC.SCM$optimal_cutpoint
table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(optimal_mac_C3_SCM_cow))
##
## FALSE TRUE
## 286 144
prop.table(table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(optimal_mac_C3_SCM_cow)))
##
## FALSE TRUE
## 0.6651163 0.3348837
# confidence intervals
table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(MAC.SCM_lower_ci))
##
## FALSE TRUE
## 270 160
prop.table(table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(MAC.SCM_lower_ci)))
##
## FALSE TRUE
## 0.627907 0.372093
table(Pc.by.cow.C3$TOTAL.MAC.CO.COW > exp(MAC.SCM_upper_ci))
##
## FALSE TRUE
## 335 95
prop.table(table(Pc.by.cow.C3$TOTAL.MAC.CO.COW >exp(MAC.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7790698 0.2209302
# Percent MAC
# optimal cut-off
optimal_per_mac_C3_SCM_cow <- PER.MAC.SCM$optimal_cutpoint
table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > optimal_per_mac_C3_SCM_cow)
##
## FALSE TRUE
## 241 189
prop.table(table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > optimal_per_mac_C3_SCM_cow))
##
## FALSE TRUE
## 0.5604651 0.4395349
# confidence intervals
table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > PER.MAC.SCM_lower_ci)
##
## FALSE TRUE
## 216 214
prop.table(table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > PER.MAC.SCM_lower_ci))
##
## FALSE TRUE
## 0.5023256 0.4976744
table(Pc.by.cow.C3$PERCENT.MAC.CO.COW > PER.MAC.SCM_upper_ci)
##
## FALSE TRUE
## 280 150
prop.table(table(Pc.by.cow.C3$PERCENT.MAC.CO.COW >PER.MAC.SCM_upper_ci))
##
## FALSE TRUE
## 0.6511628 0.3488372
# Set a seed for reproducibility
set.seed(123)
# IMI quarter referent
# SCC IMI cow
SCC.IMI <- cutpointr(Pc.by.quarter.C3, log.SCC, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(SCC.IMI)
## Method: maximize_metric
## Predictor: log.SCC
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4941 1590 1046 544
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.7612 1.0279 0.6396 0.912 0.1158 0.6648 0.4065
## tp fn fp tn
## 954 92 481 63
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.791759 3.526361 4.248495 4.709530 4.782004 5.214936 6.217703
## 0 1.945910 3.533607 4.248495 4.718499 4.757269 5.185985 6.098074
## 1 1.791759 3.401197 4.244898 4.709530 4.829564 5.279387 6.878855
## Max. SD NAs
## 8.660081 0.8996189 0
## 8.326275 0.8273682 0
## 8.660081 1.0234700 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 1.95 3.30 3.71 3.76 4.04 4.64 4.88 5.66 0.53 0
## AUC_b 0.44 0.47 0.48 0.49 0.49 0.50 0.52 0.55 0.02 0
## AUC_oob 0.43 0.46 0.48 0.50 0.49 0.51 0.53 0.56 0.02 0
## sum_sens_spec_b 1.00 1.02 1.03 1.04 1.04 1.05 1.07 1.12 0.02 0
## sum_sens_spec_oob 0.87 0.94 0.98 1.00 1.00 1.02 1.04 1.08 0.03 0
## acc_b 0.37 0.49 0.54 0.63 0.60 0.65 0.67 0.70 0.06 0
## acc_oob 0.36 0.45 0.52 0.62 0.58 0.64 0.66 0.70 0.07 0
## sensitivity_b 0.12 0.42 0.58 0.91 0.78 0.93 0.99 1.00 0.20 0
## sensitivity_oob 0.11 0.39 0.56 0.89 0.77 0.92 0.98 1.00 0.21 0
## specificity_b 0.00 0.04 0.11 0.14 0.26 0.47 0.63 0.90 0.20 0
## specificity_oob 0.00 0.03 0.09 0.13 0.23 0.42 0.58 0.82 0.19 0
## cohens_kappa_b 0.00 0.02 0.03 0.04 0.04 0.05 0.07 0.11 0.02 0
## cohens_kappa_oob -0.10 -0.06 -0.02 0.00 0.00 0.02 0.04 0.09 0.03 0
## ppv_b 0.63 0.65 0.66 0.67 0.67 0.68 0.69 0.73 0.01 0
## ppv_oob 0.53 0.62 0.64 0.66 0.66 0.67 0.68 0.72 0.02 0
## npv_b 0.32 0.35 0.37 0.40 0.42 0.45 0.59 1.00 0.08 0
## npv_oob 0.17 0.29 0.32 0.35 0.37 0.40 0.53 0.80 0.08 2
# ROC plot
plot(SCC.IMI)
# Youden index plot
plot_metric(SCC.IMI)
# NEU IMI cow
NEU.IMI <- cutpointr(Pc.by.quarter.C3, log.Neu, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.IMI)
## Method: maximize_metric
## Predictor: log.Neu
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5278 1594 544 1050
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.6376 1.0518 0.4542 0.7518 0.3 0.3575 0.7 409
## fn fp tn
## 135 735 315
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.609438 2.833213 3.555348 4.025352 4.128486 4.584967 5.652652
## 0 1.609438 2.833213 3.526361 4.007333 4.083754 4.564348 5.497954
## 1 1.609438 2.833213 3.637586 4.077537 4.214824 4.656330 6.099611
## Max. SD NAs
## 9.429396 0.9611833 0
## 8.848940 0.8999282 0
## 9.429396 1.0651172 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.77 3.61 3.64 4.09 4.25 4.64 5.38 7.97 0.64 0
## AUC_b 0.47 0.50 0.52 0.53 0.53 0.54 0.55 0.58 0.02 0
## AUC_oob 0.46 0.49 0.51 0.53 0.53 0.54 0.56 0.59 0.02 0
## sum_sens_spec_b 1.02 1.04 1.05 1.07 1.07 1.08 1.10 1.14 0.02 0
## sum_sens_spec_oob 0.89 0.97 1.00 1.02 1.02 1.04 1.06 1.11 0.03 0
## acc_b 0.36 0.45 0.47 0.54 0.55 0.62 0.66 0.69 0.08 0
## acc_oob 0.33 0.42 0.45 0.52 0.52 0.59 0.65 0.69 0.08 0
## sensitivity_b 0.03 0.10 0.27 0.51 0.49 0.75 0.79 0.99 0.25 0
## sensitivity_oob 0.01 0.08 0.23 0.47 0.46 0.73 0.77 0.94 0.25 0
## specificity_b 0.05 0.28 0.31 0.56 0.57 0.79 0.95 1.00 0.24 0
## specificity_oob 0.03 0.26 0.30 0.54 0.56 0.77 0.94 0.99 0.24 0
## cohens_kappa_b 0.02 0.03 0.05 0.06 0.06 0.07 0.10 0.13 0.02 0
## cohens_kappa_oob -0.10 -0.03 0.00 0.02 0.01 0.03 0.06 0.09 0.03 0
## ppv_b 0.32 0.35 0.36 0.38 0.40 0.41 0.51 0.93 0.05 0
## ppv_oob 0.23 0.31 0.34 0.35 0.36 0.37 0.45 0.59 0.04 0
## npv_b 0.64 0.66 0.68 0.69 0.69 0.71 0.73 0.86 0.02 0
## npv_oob 0.48 0.63 0.65 0.67 0.67 0.68 0.71 0.75 0.02 0
# ROC plot
plot(NEU.IMI)
# Youden index plot
plot_metric(NEU.IMI)
# %NEU IMI cow
PER.NEU.IMI <- cutpointr(Pc.by.quarter.C3, PERCENT01_N, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.IMI)
## Method: maximize_metric
## Predictor: PERCENT01_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5265 1594 544 1050
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 59.65 1.0575 0.5245 0.5423 0.5152 0.3669 0.6848
## tp fn fp tn
## 295 249 509 541
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 20.16 38.920 51.3925 59.700 59.01367 67.5150 76.6035 87.31 11.49611
## 0 20.16 37.931 50.7325 59.190 58.64175 67.2550 76.2700 87.14 11.66787
## 1 26.92 39.793 52.8600 60.525 59.73153 68.0525 76.7355 87.31 11.13256
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 32.91 48.94 52.88 57.84 56.78 59.70 63.45 76.67 4.98
## AUC_b 0.47 0.50 0.52 0.53 0.53 0.54 0.55 0.57 0.01
## AUC_oob 0.46 0.50 0.51 0.53 0.53 0.54 0.56 0.59 0.02
## sum_sens_spec_b 1.01 1.04 1.06 1.07 1.07 1.09 1.11 1.16 0.02
## sum_sens_spec_oob 0.91 0.97 1.01 1.03 1.03 1.05 1.08 1.14 0.03
## acc_b 0.36 0.43 0.46 0.51 0.50 0.54 0.58 0.68 0.05
## acc_oob 0.33 0.41 0.45 0.49 0.48 0.52 0.56 0.66 0.05
## sensitivity_b 0.06 0.41 0.54 0.61 0.63 0.76 0.84 0.99 0.15
## sensitivity_oob 0.03 0.37 0.50 0.58 0.60 0.73 0.83 0.99 0.15
## specificity_b 0.02 0.22 0.31 0.46 0.44 0.54 0.66 0.97 0.15
## specificity_oob 0.02 0.20 0.30 0.44 0.42 0.53 0.64 0.95 0.15
## cohens_kappa_b 0.01 0.03 0.05 0.06 0.06 0.08 0.10 0.15 0.02
## cohens_kappa_oob -0.08 -0.02 0.01 0.02 0.02 0.04 0.07 0.12 0.03
## ppv_b 0.32 0.34 0.36 0.37 0.37 0.38 0.40 0.50 0.02
## ppv_oob 0.23 0.31 0.34 0.35 0.35 0.37 0.39 0.42 0.02
## npv_b 0.64 0.67 0.69 0.70 0.70 0.72 0.74 0.89 0.02
## npv_oob 0.58 0.64 0.66 0.68 0.68 0.69 0.72 0.83 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.IMI)
# Youden index plot
plot_metric(PER.NEU.IMI)
# LYM IMI cow
LYM.IMI <- cutpointr(Pc.by.quarter.C3, log.Lym, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.IMI)
## Method: maximize_metric
## Predictor: log.Lym
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5235 1594 544 1050
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 2.8904 1.0542 0.51 0.5809 0.4733 0.3636 0.6855 316
## fn fp tn
## 228 553 497
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 1.609438 2.419648 2.944439 3.001466 3.465736 4.488636 7.219642
## 0 0 1.609438 2.397895 2.890372 2.964868 3.433987 4.356709 7.195187
## 1 0 1.609438 2.484907 2.995732 3.072105 3.526361 4.850854 7.219642
## SD NAs
## 0.9397576 0
## 0.8925654 0
## 1.0218769 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 1.95 2.83 2.89 3.00 3.31 3.56 4.49 6.58 0.64 0
## AUC_b 0.47 0.50 0.51 0.52 0.52 0.53 0.55 0.57 0.02 0
## AUC_oob 0.45 0.49 0.51 0.52 0.52 0.54 0.56 0.60 0.02 0
## sum_sens_spec_b 1.01 1.03 1.05 1.06 1.06 1.08 1.10 1.14 0.02 0
## sum_sens_spec_oob 0.92 0.97 1.00 1.03 1.02 1.04 1.07 1.14 0.03 0
## acc_b 0.39 0.50 0.52 0.53 0.56 0.62 0.67 0.70 0.06 0
## acc_oob 0.35 0.46 0.50 0.52 0.54 0.60 0.66 0.71 0.07 0
## sensitivity_b 0.02 0.08 0.25 0.54 0.44 0.59 0.64 0.92 0.22 0
## sensitivity_oob 0.02 0.06 0.21 0.51 0.41 0.57 0.62 0.88 0.21 0
## specificity_b 0.11 0.43 0.48 0.53 0.63 0.81 0.97 1.00 0.21 0
## specificity_oob 0.07 0.41 0.47 0.51 0.61 0.79 0.96 0.99 0.21 0
## cohens_kappa_b 0.01 0.03 0.05 0.06 0.06 0.07 0.09 0.13 0.02 0
## cohens_kappa_oob -0.08 -0.03 0.00 0.02 0.02 0.04 0.07 0.12 0.03 0
## ppv_b 0.32 0.35 0.37 0.38 0.41 0.42 0.57 0.72 0.07 0
## ppv_oob 0.23 0.31 0.34 0.36 0.37 0.38 0.50 0.69 0.06 0
## npv_b 0.64 0.66 0.67 0.68 0.69 0.70 0.72 0.76 0.02 0
## npv_oob 0.53 0.63 0.65 0.67 0.67 0.68 0.70 0.74 0.02 0
# ROC plot
plot(LYM.IMI)
# Youden index plot
plot_metric(LYM.IMI)
# %LYM IMI cow
PER.LYM.IMI <- cutpointr(Pc.by.quarter.C3, PERCENT02_N, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.IMI)
## Method: maximize_metric
## Predictor: PERCENT02_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5014 1594 544 1050
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 17.3 1.0312 0.468 0.6654 0.3657 0.3521 0.6784 362
## fn fp tn
## 182 666 384
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 2.70 10.3265 15.5700 19.305 19.67462 23.4400 29.6705 48.30 5.978316
## 0 2.70 10.7270 15.4925 19.230 19.69315 23.4775 29.7605 46.05 6.018691
## 1 4.53 10.0000 15.8575 19.420 19.63886 23.3350 29.4740 48.30 5.904945
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 4.53 13.69 16.35 17.31 18.87 19.41 27.83 48.30 4.53
## AUC_b 0.45 0.48 0.49 0.50 0.50 0.51 0.53 0.55 0.02
## AUC_oob 0.43 0.47 0.49 0.50 0.50 0.51 0.53 0.56 0.02
## sum_sens_spec_b 1.00 1.01 1.03 1.04 1.04 1.06 1.08 1.12 0.02
## sum_sens_spec_oob 0.87 0.94 0.98 1.00 1.00 1.01 1.04 1.09 0.03
## acc_b 0.31 0.41 0.46 0.48 0.50 0.53 0.65 0.68 0.07
## acc_oob 0.32 0.39 0.44 0.46 0.48 0.50 0.63 0.68 0.07
## sensitivity_b 0.00 0.10 0.52 0.67 0.58 0.73 0.85 1.00 0.23
## sensitivity_oob 0.00 0.08 0.48 0.64 0.55 0.70 0.83 1.00 0.24
## specificity_b 0.00 0.18 0.32 0.38 0.46 0.52 0.92 1.00 0.23
## specificity_oob 0.00 0.16 0.30 0.36 0.44 0.50 0.91 1.00 0.23
## cohens_kappa_b 0.00 0.01 0.03 0.04 0.04 0.05 0.07 0.10 0.02
## cohens_kappa_oob -0.11 -0.05 -0.02 0.00 -0.01 0.01 0.04 0.07 0.03
## ppv_b 0.31 0.34 0.35 0.36 0.37 0.38 0.42 1.00 0.04
## ppv_oob 0.00 0.28 0.32 0.34 0.34 0.35 0.37 0.50 0.03
## npv_b 0.63 0.66 0.67 0.69 0.69 0.70 0.72 1.00 0.03
## npv_oob 0.33 0.61 0.64 0.66 0.66 0.67 0.70 1.00 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 4
## 0
## 5
# ROC plot
plot(PER.LYM.IMI)
# Youden index plot
plot_metric(PER.LYM.IMI)
# MAC IMI cow
MAC.IMI <- cutpointr(Pc.by.quarter.C3, log.Mac, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.IMI)
## Method: maximize_metric
## Predictor: log.Mac
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4962 1594 1050 544
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 2.7081 1.0215 0.5439 0.6152 0.4062 0.6667 0.3536
## tp fn fp tn
## 646 404 323 221
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 1.609438 2.326413 2.890372 2.992118 3.496508 4.779472 8.986447
## 0 0 1.609438 2.397895 2.890372 2.971666 3.496508 4.626742 8.905309
## 1 0 1.386294 2.302585 2.890372 3.031595 3.526361 5.116021 8.986447
## SD NAs
## 1.070470 0
## 1.004755 0
## 1.187056 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 0.69 1.61 1.79 2.48 Inf 2.71 3.78 Inf NaN 0
## AUC_b 0.45 0.47 0.49 0.50 0.50 0.51 0.52 0.55 0.02 0
## AUC_oob 0.43 0.46 0.48 0.50 0.50 0.51 0.53 0.56 0.02 0
## sum_sens_spec_b 1.00 1.01 1.02 1.03 1.04 1.05 1.07 1.12 0.02 0
## sum_sens_spec_oob 0.89 0.94 0.97 0.99 0.99 1.01 1.04 1.09 0.03 0
## acc_b 0.33 0.41 0.55 0.58 0.57 0.63 0.66 0.69 0.07 0
## acc_oob 0.30 0.38 0.52 0.55 0.55 0.62 0.66 0.69 0.08 0
## sensitivity_b 0.00 0.18 0.61 0.71 0.68 0.91 0.97 1.00 0.23 0
## sensitivity_oob 0.00 0.15 0.59 0.69 0.67 0.90 0.96 1.00 0.23 0
## specificity_b 0.01 0.05 0.12 0.33 0.35 0.44 0.86 1.00 0.23 0
## specificity_oob 0.00 0.04 0.10 0.31 0.32 0.41 0.82 1.00 0.22 0
## cohens_kappa_b 0.00 0.01 0.02 0.03 0.04 0.05 0.07 0.12 0.02 0
## cohens_kappa_oob -0.11 -0.05 -0.02 -0.01 -0.01 0.01 0.04 0.09 0.03 0
## ppv_b 0.63 0.65 0.66 0.67 0.67 0.68 0.70 1.00 0.02 4
## ppv_oob 0.00 0.60 0.64 0.65 0.65 0.67 0.69 0.71 0.03 4
## npv_b 0.31 0.34 0.36 0.37 0.38 0.39 0.48 0.80 0.05 0
## npv_oob 0.00 0.29 0.32 0.34 0.34 0.36 0.43 0.58 0.05 1
# ROC plot
plot(MAC.IMI)
## Warning: Removed 4 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(MAC.IMI)
# %MAC Major IMI cow
PER.MAC.IMI<- cutpointr(Pc.by.quarter.C3, PERCENT03_N, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.IMI)
## Method: maximize_metric
## Predictor: PERCENT03_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.523 1594 1050 544
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 26.45 1.058 0.4536 0.2914 0.7665 0.7067 0.3592
## tp fn fp tn
## 306 744 127 417
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 1.89 7.1530 13.0425 19.310 21.31286 27.27 42.5310 72.94 11.05134 0
## 0 2.00 7.1735 13.1600 19.600 21.66627 27.77 42.3275 72.94 11.28930 0
## 1 1.89 6.9980 12.7525 18.795 20.63074 26.06 42.6460 57.35 10.55365 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 4.40 11.76 19.01 25.53 23.91 26.47 29.85 50.90 5.53
## AUC_b 0.48 0.50 0.51 0.52 0.52 0.53 0.55 0.58 0.01
## AUC_oob 0.46 0.49 0.51 0.52 0.52 0.54 0.56 0.60 0.02
## sum_sens_spec_b 1.01 1.04 1.06 1.07 1.07 1.08 1.10 1.15 0.02
## sum_sens_spec_oob 0.91 0.97 1.01 1.03 1.03 1.05 1.08 1.13 0.03
## acc_b 0.34 0.42 0.45 0.47 0.49 0.53 0.62 0.68 0.06
## acc_oob 0.33 0.41 0.43 0.45 0.47 0.50 0.59 0.68 0.05
## sensitivity_b 0.02 0.22 0.28 0.32 0.39 0.54 0.82 0.99 0.18
## sensitivity_oob 0.02 0.20 0.27 0.31 0.38 0.51 0.80 1.00 0.18
## specificity_b 0.02 0.24 0.54 0.75 0.68 0.79 0.85 1.00 0.18
## specificity_oob 0.01 0.20 0.50 0.73 0.65 0.78 0.84 0.99 0.19
## cohens_kappa_b 0.01 0.03 0.05 0.06 0.06 0.07 0.09 0.13 0.02
## cohens_kappa_oob -0.09 -0.03 0.00 0.02 0.02 0.04 0.06 0.10 0.03
## ppv_b 0.64 0.67 0.69 0.71 0.71 0.73 0.75 0.91 0.03
## ppv_oob 0.56 0.64 0.66 0.68 0.68 0.70 0.74 0.79 0.03
## npv_b 0.32 0.34 0.36 0.37 0.37 0.38 0.40 0.66 0.03
## npv_oob 0.11 0.31 0.34 0.35 0.35 0.36 0.38 0.67 0.02
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.MAC.IMI)
# Youden index plot
plot_metric(PER.MAC.IMI)
# Summary of results when using C5 and IMI as reference
print(c("Optimal SCC:", exp(SCC.IMI$optimal_cutpoint), SCC.IMI$sensitivity, SCC.IMI$specificity, SCC.IMI$ppv, SCC.IMI$npv, SCC.IMI$AUC))
## sensitivity specificity
## "Optimal SCC:" "43" "0.912045889101338" "0.115808823529412"
##
## "0.664808362369338" "0.406451612903226" "0.494115362445169"
print(c("Optimal n NEU:", exp(NEU.IMI$optimal_cutpoint), NEU.IMI$sensitivity, NEU.IMI$specificity, NEU.IMI$ppv, NEU.IMI$npv, NEU.IMI$AUC))
## sensitivity specificity
## "Optimal n NEU:" "38" "0.751838235294118" "0.3"
##
## "0.357517482517482" "0.7" "0.527754726890756"
print(c("Optimal %NEU:", PER.NEU.IMI$optimal_cutpoint, PER.NEU.IMI$sensitivity, PER.NEU.IMI$specificity, PER.NEU.IMI$ppv, PER.NEU.IMI$npv, PER.NEU.IMI$AUC))
## sensitivity specificity
## "Optimal %NEU:" "59.65" "0.542279411764706" "0.515238095238095"
##
## "0.366915422885572" "0.684810126582278" "0.526458333333333"
print(c("Optimal n LYM:", exp(LYM.IMI$optimal_cutpoint), LYM.IMI$sensitivity, LYM.IMI$specificity, LYM.IMI$ppv, LYM.IMI$npv, LYM.IMI$AUC))
## sensitivity specificity
## "Optimal n LYM:" "18" "0.580882352941177" "0.473333333333333"
##
## "0.363636363636364" "0.68551724137931" "0.523480392156863"
print(c("Optimal %LYM:", PER.LYM.IMI$optimal_cutpoint, PER.LYM.IMI$sensitivity, PER.LYM.IMI$specificity, PER.LYM.IMI$ppv, PER.LYM.IMI$npv, PER.LYM.IMI$AUC))
## sensitivity specificity
## "Optimal %LYM:" "17.3" "0.665441176470588" "0.365714285714286"
##
## "0.352140077821012" "0.678445229681979" "0.501424194677871"
print(c("Optimal n MAC:", exp(MAC.IMI$optimal_cutpoint), MAC.IMI$sensitivity, MAC.IMI$specificity, MAC.IMI$ppv, MAC.IMI$npv, MAC.IMI$AUC))
## sensitivity specificity
## "Optimal n MAC:" "15" "0.615238095238095" "0.40625"
##
## "0.666666666666667" "0.3536" "0.496233368347339"
print(c("Optimal %MAC:", PER.MAC.IMI$optimal_cutpoint, PER.MAC.IMI$sensitivity, PER.MAC.IMI$specificity, PER.MAC.IMI$ppv, PER.MAC.IMI$npv, PER.MAC.IMI$AUC))
## sensitivity specificity
## "Optimal %MAC:" "26.45" "0.291428571428571" "0.766544117647059"
##
## "0.706697459584296" "0.359173126614987" "0.523040966386555"
# SCC.IMI
SCC.IMI_optimal_cutpoint <- boot_ci(SCC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
SCC.IMI_lower_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(SCC.IMI_lower_ci)
## [1] 27
SCC.IMI_upper_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(SCC.IMI_upper_ci)
## [1] 139
boot_ci(SCC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.395
## 2 0.975 0.988
boot_ci(SCC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0314
## 2 0.975 0.651
boot_ci(SCC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.645
## 2 0.975 0.700
boot_ci(SCC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.345
## 2 0.975 0.629
boot_ci(SCC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.464
## 2 0.975 0.525
# NEU.IMI
NEU.IMI_optimal_cutpoint <- boot_ci(NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.IMI_lower_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.IMI_lower_ci)
## [1] 36
NEU.IMI_upper_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.IMI_upper_ci)
## [1] 269
boot_ci(NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0844
## 2 0.975 0.797
boot_ci(NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.274
## 2 0.975 0.958
boot_ci(NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.340
## 2 0.975 0.536
boot_ci(NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.656
## 2 0.975 0.741
boot_ci(NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.497
## 2 0.975 0.558
# PER.NEU.IMI
PER.NEU.IMI_optimal_cutpoint <- boot_ci(PER.NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 47.4
## 2 0.975 67.1
PER.NEU.IMI_lower_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.IMI_upper_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.317
## 2 0.975 0.865
boot_ci(PER.NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.192
## 2 0.975 0.743
boot_ci(PER.NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.339
## 2 0.975 0.411
boot_ci(PER.NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.664
## 2 0.975 0.752
boot_ci(PER.NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.497
## 2 0.975 0.555
# LYM.IMI
LYM.IMI_optimal_cutpoint <- boot_ci(LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.IMI_lower_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.IMI_lower_ci)
## [1] 13
LYM.IMI_upper_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.IMI_upper_ci)
## [1] 105
boot_ci(LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0662
## 2 0.975 0.768
boot_ci(LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.291
## 2 0.975 0.973
boot_ci(LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.345
## 2 0.975 0.6
boot_ci(LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.653
## 2 0.975 0.723
boot_ci(LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.493
## 2 0.975 0.554
# PER.LYM.IMI
PER.LYM.IMI_optimal_cutpoint <- boot_ci(PER.LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 13.5
## 2 0.975 28.0
PER.LYM.IMI_lower_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.IMI_upper_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0922
## 2 0.975 0.885
boot_ci(PER.LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.151
## 2 0.975 0.930
boot_ci(PER.LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.330
## 2 0.975 0.445
boot_ci(PER.LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.651
## 2 0.975 0.739
boot_ci(PER.LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.471
## 2 0.975 0.532
# MAC.IMI
MAC.IMI_optimal_cutpoint <- boot_ci(MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.IMI_lower_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.IMI_lower_ci)
## [1] 5
MAC.IMI_upper_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.IMI_upper_ci)
## [1] 57
boot_ci(MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.140
## 2 0.975 0.970
boot_ci(MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0436
## 2 0.975 0.884
boot_ci(MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.645
## 2 0.975 0.714
boot_ci(MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.334
## 2 0.975 0.5
boot_ci(MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.467
## 2 0.975 0.526
# PER.MAC.IMI
PER.MAC.IMI_optimal_cutpoint <- boot_ci(PER.MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 10.7
## 2 0.975 33.3
PER.MAC.IMI_lower_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.IMI_upper_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.166
## 2 0.975 0.856
boot_ci(PER.MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.201
## 2 0.975 0.883
boot_ci(PER.MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.664
## 2 0.975 0.758
boot_ci(PER.MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.338
## 2 0.975 0.423
boot_ci(PER.MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.494
## 2 0.975 0.551
# Prevalence
# True prevalence
table(Pc.by.quarter.C3$IMI)
##
## 0 1
## 1050 545
prop.table(table(Pc.by.quarter.C3$IMI))
##
## 0 1
## 0.6583072 0.3416928
#Apparent prevalence
# ---- SCC ----
# optimal cut-off
optimal_scc_C3_IMI_quarter <- SCC.IMI$optimal_cutpoint
table(Pc.by.quarter.C3$test_result_n > exp(optimal_scc_C3_IMI_quarter))
##
## FALSE TRUE
## 179 1501
prop.table(table(Pc.by.quarter.C3$test_result_n > exp(optimal_scc_C3_IMI_quarter)))
##
## FALSE TRUE
## 0.1065476 0.8934524
# confidence intervals
table(Pc.by.quarter.C3$test_result_n > exp(SCC.IMI_lower_ci))
##
## FALSE TRUE
## 48 1632
prop.table(table(Pc.by.quarter.C3$test_result_n > exp(SCC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.02857143 0.97142857
table(Pc.by.quarter.C3$test_result_n > exp(SCC.IMI_upper_ci))
##
## FALSE TRUE
## 1033 647
prop.table(table(Pc.by.quarter.C3$test_result_n >exp(SCC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.614881 0.385119
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C3_IMI_quarter <- NEU.IMI$optimal_cutpoint
table(Pc.by.quarter.C3$TOTAL01_N > exp(optimal_neu_C3_IMI_quarter))
##
## FALSE TRUE
## 477 1207
prop.table(table(Pc.by.quarter.C3$TOTAL01_N > exp(optimal_neu_C3_IMI_quarter)))
##
## FALSE TRUE
## 0.2832542 0.7167458
# confidence intervals
table(Pc.by.quarter.C3$TOTAL01_N > exp(NEU.IMI_lower_ci))
##
## FALSE TRUE
## 452 1232
prop.table(table(Pc.by.quarter.C3$TOTAL01_N > exp(NEU.IMI_lower_ci)))
##
## FALSE TRUE
## 0.2684086 0.7315914
table(Pc.by.quarter.C3$TOTAL01_N > exp(NEU.IMI_upper_ci))
##
## FALSE TRUE
## 1595 89
prop.table(table(Pc.by.quarter.C3$TOTAL01_N >exp(NEU.IMI_upper_ci)))
##
## FALSE TRUE
## 0.94714964 0.05285036
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C3_IMI_quarter <- PER.NEU.IMI$optimal_cutpoint
table(Pc.by.quarter.C3$PERCENT01_N > optimal_per_neu_C3_IMI_quarter)
##
## FALSE TRUE
## 841 843
prop.table(table(Pc.by.quarter.C3$PERCENT01_N > optimal_per_neu_C3_IMI_quarter))
##
## FALSE TRUE
## 0.4994062 0.5005938
# confidence intervals
table(Pc.by.quarter.C3$PERCENT01_N > PER.NEU.IMI_lower_ci)
##
## FALSE TRUE
## 282 1402
prop.table(table(Pc.by.quarter.C3$PERCENT01_N > PER.NEU.IMI_lower_ci))
##
## FALSE TRUE
## 0.1674584 0.8325416
table(Pc.by.quarter.C3$PERCENT01_N > PER.NEU.IMI_upper_ci)
##
## FALSE TRUE
## 1248 436
prop.table(table(Pc.by.quarter.C3$PERCENT01_N >PER.NEU.IMI_upper_ci))
##
## FALSE TRUE
## 0.7410926 0.2589074
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C3_IMI_quarter <-LYM.IMI$optimal_cutpoint
table(Pc.by.quarter.C3$TOTAL02_N > exp(optimal_lym_C3_IMI_quarter))
##
## FALSE TRUE
## 764 920
prop.table(table(Pc.by.quarter.C3$TOTAL02_N > exp(optimal_lym_C3_IMI_quarter)))
##
## FALSE TRUE
## 0.4536817 0.5463183
# confidence intervals
table(Pc.by.quarter.C3$TOTAL02_N > exp(LYM.IMI_lower_ci))
##
## FALSE TRUE
## 542 1142
prop.table(table(Pc.by.quarter.C3$TOTAL02_N > exp(LYM.IMI_lower_ci)))
##
## FALSE TRUE
## 0.3218527 0.6781473
table(Pc.by.quarter.C3$TOTAL02_N > exp(LYM.IMI_upper_ci))
##
## FALSE TRUE
## 1619 65
prop.table(table(Pc.by.quarter.C3$TOTAL02_N >exp(LYM.IMI_upper_ci)))
##
## FALSE TRUE
## 0.96140143 0.03859857
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C3_IMI_quarter <-PER.LYM.IMI$optimal_cutpoint
table(Pc.by.quarter.C3$PERCENT02_N > optimal_per_lym_C3_IMI_quarter)
##
## FALSE TRUE
## 609 1075
prop.table(table(Pc.by.quarter.C3$PERCENT02_N > optimal_per_lym_C3_IMI_quarter))
##
## FALSE TRUE
## 0.361639 0.638361
# confidence intervals
table(Pc.by.quarter.C3$PERCENT02_N > PER.LYM.IMI_lower_ci)
##
## FALSE TRUE
## 249 1435
prop.table(table(Pc.by.quarter.C3$PERCENT02_N > PER.LYM.IMI_lower_ci))
##
## FALSE TRUE
## 0.1478622 0.8521378
table(Pc.by.quarter.C3$PERCENT02_N > PER.LYM.IMI_upper_ci)
##
## FALSE TRUE
## 1545 139
prop.table(table(Pc.by.quarter.C3$PERCENT02_N >PER.LYM.IMI_upper_ci))
##
## FALSE TRUE
## 0.91745843 0.08254157
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C3_IMI_quarter <- MAC.IMI$optimal_cutpoint
table(Pc.by.quarter.C3$TOTAL03_N > exp(optimal_mac_C3_IMI_quarter))
##
## FALSE TRUE
## 701 983
prop.table(table(Pc.by.quarter.C3$TOTAL03_N > exp(optimal_mac_C3_IMI_quarter)))
##
## FALSE TRUE
## 0.4162708 0.5837292
# confidence intervals
table(Pc.by.quarter.C3$TOTAL03_N > exp(MAC.IMI_lower_ci))
##
## FALSE TRUE
## 75 1609
prop.table(table(Pc.by.quarter.C3$TOTAL03_N > exp(MAC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.04453682 0.95546318
table(Pc.by.quarter.C3$TOTAL03_N > exp(MAC.IMI_upper_ci))
##
## FALSE TRUE
## 1463 221
prop.table(table(Pc.by.quarter.C3$TOTAL03_N >exp(MAC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.8687648 0.1312352
# Percent MAC
# optimal cut-off
optimal_per_mac_C3_IMI_quarter <- PER.MAC.IMI$optimal_cutpoint
table(Pc.by.quarter.C3$PERCENT03_N > optimal_per_mac_C3_IMI_quarter)
##
## FALSE TRUE
## 1223 461
prop.table(table(Pc.by.quarter.C3$PERCENT03_N > optimal_per_mac_C3_IMI_quarter))
##
## FALSE TRUE
## 0.726247 0.273753
# confidence intervals
table(Pc.by.quarter.C3$PERCENT03_N > PER.MAC.IMI_lower_ci)
##
## FALSE TRUE
## 268 1416
prop.table(table(Pc.by.quarter.C3$PERCENT03_N > PER.MAC.IMI_lower_ci))
##
## FALSE TRUE
## 0.1591449 0.8408551
table(Pc.by.quarter.C3$PERCENT03_N > PER.MAC.IMI_upper_ci)
##
## FALSE TRUE
## 1446 238
prop.table(table(Pc.by.quarter.C3$PERCENT03_N >PER.MAC.IMI_upper_ci))
##
## FALSE TRUE
## 0.8586698 0.1413302
# Set a seed for reproducibility
set.seed(123)
# Qscout subclinical mastitis reference
# n NEU SCM quarter
NEU.delaval.SCM <- cutpointr(Pc.by.quarter.C3, log.Neu, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Neu
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.8559 1679 365 1314
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.4427 1.5665 0.8017 0.7507 0.8158 0.531 0.9218 274
## fn fp tn
## 91 242 1072
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.609438 2.833213 3.555348 4.043051 4.134314 4.595120 5.650025
## 0 1.609438 2.772589 3.401197 3.871201 3.860068 4.290459 5.022112
## 1 2.833213 3.806662 4.442651 4.927254 5.121600 5.480639 7.497096
## Max. SD NAs
## 9.429396 0.9643956 0
## 7.668094 0.6986908 0
## 9.429396 1.1303368 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 4.22 4.38 4.44 4.45 4.46 4.50 4.52 4.71 0.05 0
## AUC_b 0.82 0.84 0.85 0.86 0.86 0.86 0.87 0.90 0.01 0
## AUC_oob 0.81 0.83 0.85 0.86 0.86 0.87 0.88 0.90 0.01 0
## sum_sens_spec_b 1.49 1.53 1.55 1.57 1.57 1.59 1.61 1.68 0.02 0
## sum_sens_spec_oob 1.41 1.50 1.53 1.55 1.55 1.58 1.61 1.67 0.03 0
## acc_b 0.73 0.78 0.80 0.81 0.81 0.82 0.83 0.85 0.01 0
## acc_oob 0.69 0.77 0.79 0.80 0.80 0.81 0.83 0.85 0.02 0
## sensitivity_b 0.61 0.71 0.73 0.75 0.75 0.77 0.80 0.86 0.03 0
## sensitivity_oob 0.53 0.68 0.71 0.74 0.74 0.76 0.80 0.85 0.04 0
## specificity_b 0.71 0.78 0.81 0.82 0.82 0.83 0.85 0.90 0.02 0
## specificity_oob 0.66 0.78 0.80 0.82 0.82 0.83 0.85 0.91 0.02 0
## cohens_kappa_b 0.38 0.46 0.48 0.50 0.50 0.52 0.54 0.58 0.03 0
## cohens_kappa_oob 0.34 0.43 0.46 0.49 0.49 0.51 0.54 0.60 0.03 0
## ppv_b 0.42 0.49 0.52 0.54 0.54 0.56 0.58 0.65 0.03 0
## ppv_oob 0.40 0.47 0.51 0.53 0.53 0.55 0.59 0.67 0.03 0
## npv_b 0.88 0.91 0.92 0.92 0.92 0.93 0.94 0.96 0.01 0
## npv_oob 0.86 0.90 0.91 0.92 0.92 0.93 0.94 0.95 0.01 0
# ROC plot
plot(NEU.delaval.SCM)
# Youden index plot
plot_metric(NEU.delaval.SCM)
# %NEU SCM quarter
PER.NEU.delaval.SCM <- cutpointr(Pc.by.quarter.C3, PERCENT01_N, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT01_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.582 1679 1314 365
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 46.43 1.1572 0.757 0.8942 0.263 0.8137 0.4085
## tp fn fp tn
## 1175 139 269 96
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 20.16 38.910 51.365 59.650 58.93719 67.410 76.400 87.31 11.46029 0
## 0 21.28 41.670 52.315 60.195 59.79792 67.815 76.400 87.31 10.81338 0
## 1 20.16 33.364 46.100 57.140 55.83858 65.210 75.878 84.56 13.09094 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 41.38 43.20 46.43 46.43 47.98 47.62 61.10 65.30 4.73
## AUC_b 0.52 0.55 0.57 0.58 0.58 0.59 0.61 0.64 0.02
## AUC_oob 0.51 0.55 0.57 0.58 0.58 0.60 0.62 0.66 0.02
## sum_sens_spec_b 1.08 1.12 1.15 1.16 1.16 1.18 1.20 1.25 0.02
## sum_sens_spec_oob 1.00 1.07 1.11 1.14 1.13 1.16 1.19 1.27 0.04
## acc_b 0.45 0.53 0.74 0.76 0.73 0.77 0.78 0.81 0.07
## acc_oob 0.41 0.49 0.73 0.75 0.72 0.76 0.78 0.81 0.08
## sensitivity_b 0.37 0.49 0.87 0.89 0.85 0.90 0.94 0.96 0.13
## sensitivity_oob 0.32 0.46 0.87 0.89 0.84 0.90 0.93 0.96 0.14
## specificity_b 0.16 0.21 0.25 0.27 0.31 0.30 0.67 0.82 0.13
## specificity_oob 0.12 0.19 0.23 0.26 0.29 0.29 0.62 0.75 0.12
## cohens_kappa_b 0.06 0.10 0.16 0.18 0.18 0.20 0.22 0.28 0.04
## cohens_kappa_oob 0.00 0.05 0.13 0.16 0.15 0.18 0.22 0.31 0.05
## ppv_b 0.78 0.80 0.81 0.82 0.82 0.82 0.84 0.88 0.01
## ppv_oob 0.76 0.79 0.80 0.81 0.81 0.82 0.83 0.85 0.01
## npv_b 0.22 0.26 0.38 0.41 0.40 0.44 0.48 0.58 0.06
## npv_oob 0.18 0.24 0.34 0.39 0.38 0.42 0.47 0.60 0.07
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.delaval.SCM)
# Youden index plot
plot_metric(PER.NEU.delaval.SCM)
# LYM SCM quarter
LYM.delaval.SCM <- cutpointr(Pc.by.quarter.C3, log.Lym, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Lym
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.8959 1679 365 1314
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.3673 1.6472 0.8338 0.8055 0.8417 0.5857 0.9397
## tp fn fp tn
## 294 71 208 1106
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.609438 2.484907 2.944439 3.007395 3.496508 4.488636
## 0 0.000000 1.609438 2.302585 2.772589 2.715713 3.178054 3.737670
## 1 1.609438 2.784714 3.465736 3.891820 4.057452 4.406719 6.473399
## Max. SD NAs
## 7.219642 0.9427204 0
## 6.626718 0.6824364 0
## 7.219642 1.0021081 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.18 3.26 3.37 3.37 3.37 3.37 3.47 3.58 0.06 0
## AUC_b 0.86 0.88 0.89 0.90 0.90 0.90 0.91 0.92 0.01 0
## AUC_oob 0.84 0.88 0.89 0.90 0.90 0.91 0.92 0.93 0.01 0
## sum_sens_spec_b 1.56 1.61 1.63 1.65 1.65 1.66 1.68 1.74 0.02 0
## sum_sens_spec_oob 1.53 1.58 1.62 1.64 1.64 1.66 1.69 1.75 0.03 0
## acc_b 0.77 0.80 0.83 0.84 0.83 0.84 0.86 0.89 0.02 0
## acc_oob 0.76 0.79 0.82 0.83 0.83 0.84 0.85 0.89 0.02 0
## sensitivity_b 0.68 0.76 0.79 0.81 0.81 0.83 0.86 0.91 0.03 0
## sensitivity_oob 0.64 0.73 0.78 0.80 0.80 0.82 0.86 0.92 0.04 0
## specificity_b 0.76 0.79 0.83 0.84 0.84 0.85 0.88 0.93 0.03 0
## specificity_oob 0.74 0.78 0.83 0.84 0.84 0.85 0.88 0.93 0.03 0
## cohens_kappa_b 0.46 0.52 0.55 0.57 0.57 0.59 0.62 0.67 0.03 0
## cohens_kappa_oob 0.42 0.50 0.54 0.56 0.56 0.58 0.61 0.68 0.03 0
## ppv_b 0.48 0.53 0.57 0.59 0.59 0.61 0.65 0.76 0.04 0
## ppv_oob 0.43 0.51 0.56 0.58 0.58 0.61 0.64 0.72 0.04 0
## npv_b 0.91 0.93 0.93 0.94 0.94 0.95 0.95 0.97 0.01 0
## npv_oob 0.89 0.92 0.93 0.94 0.94 0.95 0.96 0.97 0.01 0
# ROC plot
plot(LYM.delaval.SCM)
# Youden index plot
plot_metric(LYM.delaval.SCM)
# %LYM SCM quarter
PER.LYM.delaval.SCM <- cutpointr(Pc.by.quarter.C3, PERCENT02_N, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT02_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5001 1679 365 1314
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 15.96 1.0385 0.3853 0.7562 0.2823 0.2264 0.8065
## tp fn fp tn
## 276 89 943 371
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 2.70 10.3290 15.5700 19.25 19.64905 23.385 29.703 48.3 5.974163 0
## 0 2.70 10.2795 15.4575 19.23 19.69201 23.455 30.230 48.3 6.126172 0
## 1 3.97 10.8440 16.0000 19.35 19.49438 23.030 28.876 35.7 5.396589 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 3.97 12.70 13.85 15.96 16.10 18.81 19.06 28.82 2.51
## AUC_b 0.45 0.47 0.49 0.50 0.50 0.51 0.53 0.56 0.02
## AUC_oob 0.42 0.46 0.48 0.50 0.50 0.51 0.54 0.57 0.02
## sum_sens_spec_b 1.00 1.02 1.04 1.05 1.05 1.07 1.09 1.13 0.02
## sum_sens_spec_oob 0.86 0.95 0.99 1.01 1.01 1.03 1.06 1.09 0.03
## acc_b 0.21 0.29 0.33 0.39 0.40 0.49 0.52 0.76 0.08
## acc_oob 0.19 0.28 0.33 0.37 0.39 0.46 0.50 0.74 0.08
## sensitivity_b 0.07 0.55 0.61 0.78 0.75 0.86 0.91 1.00 0.14
## sensitivity_oob 0.01 0.48 0.56 0.74 0.71 0.84 0.90 1.00 0.15
## specificity_b 0.00 0.12 0.18 0.28 0.31 0.46 0.50 0.94 0.14
## specificity_oob 0.00 0.11 0.18 0.27 0.30 0.44 0.49 0.93 0.14
## cohens_kappa_b 0.00 0.01 0.02 0.03 0.03 0.04 0.06 0.09 0.01
## cohens_kappa_oob -0.13 -0.03 -0.01 0.00 0.00 0.02 0.03 0.06 0.02
## ppv_b 0.19 0.21 0.22 0.23 0.23 0.24 0.25 0.31 0.01
## ppv_oob 0.06 0.19 0.21 0.22 0.22 0.23 0.24 0.27 0.02
## npv_b 0.77 0.79 0.80 0.82 0.82 0.83 0.86 1.00 0.02
## npv_oob 0.00 0.75 0.77 0.79 0.79 0.81 0.84 1.00 0.04
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 2
# ROC plot
plot(PER.LYM.delaval.SCM)
# Youden index plot
plot_metric(PER.LYM.delaval.SCM)
# MAC SCM quarter
MAC.delaval.SCM <- cutpointr(Pc.by.quarter.C3, log.Mac, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Mac
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.878 1679 365 1314
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.4012 1.5951 0.8148 0.7671 0.828 0.5534 0.9275
## tp fn fp tn
## 280 85 226 1088
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.609438 2.397895 2.944439 3.004812 3.526361 4.773195
## 0 0.000000 1.386294 2.197225 2.708050 2.683366 3.178054 3.850148
## 1 1.609438 2.639057 3.401197 4.025352 4.162018 4.644391 6.726675
## Max. SD NAs
## 8.986447 1.0721298 0
## 7.136483 0.7725831 0
## 8.986447 1.1958438 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.00 3.22 3.40 3.40 3.40 3.47 3.53 3.66 0.09 0
## AUC_b 0.84 0.86 0.87 0.88 0.88 0.88 0.89 0.91 0.01 0
## AUC_oob 0.83 0.86 0.87 0.88 0.88 0.89 0.90 0.92 0.01 0
## sum_sens_spec_b 1.52 1.56 1.58 1.60 1.60 1.62 1.64 1.68 0.02 0
## sum_sens_spec_oob 1.44 1.52 1.56 1.58 1.58 1.60 1.64 1.69 0.03 0
## acc_b 0.70 0.77 0.81 0.82 0.82 0.83 0.85 0.87 0.02 0
## acc_oob 0.68 0.76 0.80 0.82 0.81 0.83 0.84 0.87 0.02 0
## sensitivity_b 0.64 0.71 0.74 0.76 0.77 0.79 0.84 0.91 0.04 0
## sensitivity_oob 0.54 0.67 0.72 0.75 0.75 0.78 0.83 0.91 0.05 0
## specificity_b 0.64 0.75 0.82 0.84 0.83 0.86 0.88 0.92 0.04 0
## specificity_oob 0.63 0.74 0.81 0.83 0.83 0.85 0.88 0.92 0.04 0
## cohens_kappa_b 0.37 0.46 0.51 0.53 0.53 0.55 0.58 0.64 0.04 0
## cohens_kappa_oob 0.34 0.44 0.49 0.52 0.51 0.54 0.57 0.64 0.04 0
## ppv_b 0.40 0.48 0.54 0.57 0.56 0.59 0.63 0.72 0.04 0
## ppv_oob 0.38 0.47 0.53 0.55 0.55 0.58 0.63 0.70 0.05 0
## npv_b 0.90 0.91 0.92 0.93 0.93 0.93 0.95 0.96 0.01 0
## npv_oob 0.87 0.90 0.92 0.92 0.92 0.93 0.94 0.97 0.01 0
# ROC plot
plot(MAC.delaval.SCM)
# Youden index plot
plot_metric(MAC.delaval.SCM)
# %MAC SCM quarter
PER.MAC.delaval.SCM<- cutpointr(Pc.by.quarter.C3, PERCENT03_N, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT03_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5758 1679 365 1314
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 30.39 1.1658 0.7296 0.3233 0.8425 0.3631 0.8176
## tp fn fp tn
## 118 247 207 1107
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 1.89 7.1870 13.110 19.39 21.41483 27.385 43.0030 72.94 11.08192 0
## 0 1.89 7.3465 12.995 18.98 20.51173 26.335 38.4035 67.91 10.05564 0
## 1 1.94 7.1360 13.600 21.95 24.66600 34.300 49.7020 72.94 13.70595 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 18.97 23.40 30.39 32.12 31.35 33.11 34.30 42.51 2.89
## AUC_b 0.52 0.55 0.56 0.58 0.58 0.59 0.60 0.64 0.02
## AUC_oob 0.48 0.54 0.56 0.58 0.58 0.59 0.61 0.67 0.02
## sum_sens_spec_b 1.11 1.13 1.16 1.17 1.17 1.19 1.21 1.27 0.02
## sum_sens_spec_oob 1.01 1.08 1.12 1.15 1.15 1.17 1.20 1.27 0.04
## acc_b 0.53 0.64 0.73 0.75 0.74 0.76 0.77 0.80 0.04
## acc_oob 0.49 0.61 0.72 0.74 0.73 0.75 0.77 0.81 0.04
## sensitivity_b 0.15 0.25 0.28 0.31 0.32 0.34 0.49 0.66 0.07
## sensitivity_oob 0.14 0.22 0.26 0.29 0.30 0.32 0.43 0.53 0.06
## specificity_b 0.50 0.68 0.85 0.87 0.86 0.89 0.91 0.97 0.06
## specificity_oob 0.49 0.66 0.84 0.87 0.85 0.89 0.91 0.98 0.07
## cohens_kappa_b 0.09 0.14 0.17 0.19 0.19 0.20 0.23 0.29 0.03
## cohens_kappa_oob 0.00 0.07 0.13 0.16 0.16 0.19 0.22 0.32 0.04
## ppv_b 0.26 0.30 0.36 0.39 0.39 0.42 0.46 0.60 0.05
## ppv_oob 0.20 0.26 0.33 0.37 0.37 0.40 0.45 0.65 0.05
## npv_b 0.78 0.80 0.81 0.82 0.82 0.83 0.84 0.86 0.01
## npv_oob 0.77 0.79 0.80 0.81 0.81 0.82 0.84 0.87 0.01
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.MAC.delaval.SCM)
# Youden index plot
plot_metric(PER.MAC.delaval.SCM)
# Summary of results when using SCM as reference
print(c("Optimal n NEU:", exp(NEU.delaval.SCM$optimal_cutpoint), NEU.delaval.SCM$sensitivity, NEU.delaval.SCM$specificity, NEU.delaval.SCM$ppv, NEU.delaval.SCM$npv, NEU.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n NEU:" "85" "0.750684931506849" "0.815829528158295"
##
## "0.531007751937985" "0.921754084264832" "0.855941285627906"
print(c("Optimal %NEU:", PER.NEU.delaval.SCM$optimal_cutpoint, PER.NEU.delaval.SCM$sensitivity, PER.NEU.delaval.SCM$specificity, PER.NEU.delaval.SCM$ppv, PER.NEU.delaval.SCM$npv, PER.NEU.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %NEU:" "46.43" "0.894216133942161" "0.263013698630137"
##
## "0.813711911357341" "0.408510638297872" "0.582028106169596"
print(c("Optimal n LYM:", exp(LYM.delaval.SCM$optimal_cutpoint), LYM.delaval.SCM$sensitivity, LYM.delaval.SCM$specificity, LYM.delaval.SCM$ppv, LYM.delaval.SCM$npv, LYM.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n LYM:" "29" "0.805479452054795" "0.841704718417047"
##
## "0.585657370517928" "0.939677145284622" "0.895938366589521"
print(c("Optimal %LYM:", PER.LYM.delaval.SCM$optimal_cutpoint, PER.LYM.delaval.SCM$sensitivity, PER.LYM.delaval.SCM$specificity, PER.LYM.delaval.SCM$ppv, PER.LYM.delaval.SCM$npv, PER.LYM.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %LYM:" "15.96" "0.756164383561644" "0.28234398782344"
##
## "0.226415094339623" "0.806521739130435" "0.50011050645316"
print(c("Optimal n MAC:", exp(MAC.delaval.SCM$optimal_cutpoint), MAC.delaval.SCM$sensitivity, MAC.delaval.SCM$specificity, MAC.delaval.SCM$ppv, MAC.delaval.SCM$npv, MAC.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n MAC:" "30" "0.767123287671233" "0.828006088280061"
##
## "0.553359683794466" "0.927536231884058" "0.87804049123246"
print(c("Optimal %MAC:", PER.MAC.delaval.SCM$optimal_cutpoint, PER.MAC.delaval.SCM$sensitivity, PER.MAC.delaval.SCM$specificity, PER.MAC.delaval.SCM$ppv, PER.MAC.delaval.SCM$npv, PER.MAC.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %MAC:" "30.39" "0.323287671232877" "0.842465753424658"
##
## "0.363076923076923" "0.817577548005908" "0.57584391484748"
# NEU.delaval.SCM
NEU.delaval.SCM_optimal_cutpoint <- boot_ci(NEU.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.delaval.SCM_lower_ci <- subset(NEU.delaval.SCM_optimal_cutpoint, NEU.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.delaval.SCM_lower_ci)
## [1] 80
NEU.delaval.SCM_upper_ci <- subset(NEU.delaval.SCM_optimal_cutpoint, NEU.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.delaval.SCM_upper_ci)
## [1] 93
boot_ci(NEU.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.698
## 2 0.975 0.806
boot_ci(NEU.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.776
## 2 0.975 0.855
boot_ci(NEU.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.480
## 2 0.975 0.594
boot_ci(NEU.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.906
## 2 0.975 0.939
boot_ci(NEU.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.835
## 2 0.975 0.876
# PER.NEU.delaval.SCM
PER.NEU.delaval.SCM_optimal_cutpoint <- boot_ci(PER.NEU.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 42.8
## 2 0.975 61.2
PER.NEU.delaval.SCM_lower_ci <- subset(PER.NEU.delaval.SCM_optimal_cutpoint, PER.NEU.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.delaval.SCM_upper_ci <- subset(PER.NEU.delaval.SCM_optimal_cutpoint, PER.NEU.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.471
## 2 0.975 0.942
boot_ci(PER.NEU.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.196
## 2 0.975 0.693
boot_ci(PER.NEU.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.795
## 2 0.975 0.850
boot_ci(PER.NEU.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.256
## 2 0.975 0.507
boot_ci(PER.NEU.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.546
## 2 0.975 0.614
# LYM.delaval.SCM
LYM.delaval.SCM_optimal_cutpoint <- boot_ci(LYM.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.delaval.SCM_lower_ci <- subset(LYM.delaval.SCM_optimal_cutpoint, LYM.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.delaval.SCM_lower_ci)
## [1] 26
LYM.delaval.SCM_upper_ci <- subset(LYM.delaval.SCM_optimal_cutpoint, LYM.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.delaval.SCM_upper_ci)
## [1] 33
boot_ci(LYM.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.746
## 2 0.975 0.867
boot_ci(LYM.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.783
## 2 0.975 0.892
boot_ci(LYM.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.514
## 2 0.975 0.667
boot_ci(LYM.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.923
## 2 0.975 0.958
boot_ci(LYM.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.877
## 2 0.975 0.914
# PER.LYM.delaval.SCM
PER.LYM.delaval.SCM_optimal_cutpoint <- boot_ci(PER.LYM.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 10.6
## 2 0.975 20.9
PER.LYM.delaval.SCM_lower_ci <- subset(PER.LYM.delaval.SCM_optimal_cutpoint, PER.LYM.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.delaval.SCM_upper_ci <- subset(PER.LYM.delaval.SCM_optimal_cutpoint, PER.LYM.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.463
## 2 0.975 0.962
boot_ci(PER.LYM.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0613
## 2 0.975 0.604
boot_ci(PER.LYM.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.209
## 2 0.975 0.256
boot_ci(PER.LYM.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.785
## 2 0.975 0.870
boot_ci(PER.LYM.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.470
## 2 0.975 0.532
# MAC.delaval.SCM
MAC.delaval.SCM_optimal_cutpoint <- boot_ci(MAC.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.delaval.SCM_lower_ci <- subset(MAC.delaval.SCM_optimal_cutpoint, MAC.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.delaval.SCM_lower_ci)
## [1] 24
MAC.delaval.SCM_upper_ci <- subset(MAC.delaval.SCM_optimal_cutpoint, MAC.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.delaval.SCM_upper_ci)
## [1] 34
boot_ci(MAC.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.702
## 2 0.975 0.855
boot_ci(MAC.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.735
## 2 0.975 0.885
boot_ci(MAC.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.465
## 2 0.975 0.642
boot_ci(MAC.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.910
## 2 0.975 0.950
boot_ci(MAC.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.857
## 2 0.975 0.898
# PER.MAC.delaval.SCM
PER.MAC.delaval.SCM_optimal_cutpoint <- boot_ci(PER.MAC.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 22.9
## 2 0.975 34.7
PER.MAC.delaval.SCM_lower_ci <- subset(PER.MAC.delaval.SCM_optimal_cutpoint, PER.MAC.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.delaval.SCM_upper_ci <- subset(PER.MAC.delaval.SCM_optimal_cutpoint, PER.MAC.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.235
## 2 0.975 0.514
boot_ci(PER.MAC.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.662
## 2 0.975 0.918
boot_ci(PER.MAC.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.290
## 2 0.975 0.476
boot_ci(PER.MAC.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.799
## 2 0.975 0.840
boot_ci(PER.MAC.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.542
## 2 0.975 0.609
# Prevalence
# True prevalence
table(Pc.by.quarter.C3$delaval.SCM)
##
## 0 1
## 1314 366
prop.table(table(Pc.by.quarter.C3$delaval.SCM))
##
## 0 1
## 0.7821429 0.2178571
#Apparent prevalence
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C3_delaval.SCM_quarter <- NEU.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C3$TOTAL01_N > exp(optimal_neu_C3_delaval.SCM_quarter))
##
## FALSE TRUE
## 1173 511
prop.table(table(Pc.by.quarter.C3$TOTAL01_N > exp(optimal_neu_C3_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.6965558 0.3034442
# confidence intervals
table(Pc.by.quarter.C3$TOTAL01_N > exp(NEU.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1113 571
prop.table(table(Pc.by.quarter.C3$TOTAL01_N > exp(NEU.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.6609264 0.3390736
table(Pc.by.quarter.C3$TOTAL01_N > exp(NEU.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1227 457
prop.table(table(Pc.by.quarter.C3$TOTAL01_N >exp(NEU.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7286223 0.2713777
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C3_delaval.SCM_quarter <- PER.NEU.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C3$PERCENT01_N > optimal_per_neu_C3_delaval.SCM_quarter)
##
## FALSE TRUE
## 239 1445
prop.table(table(Pc.by.quarter.C3$PERCENT01_N > optimal_per_neu_C3_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.141924 0.858076
# confidence intervals
table(Pc.by.quarter.C3$PERCENT01_N > PER.NEU.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 151 1533
prop.table(table(Pc.by.quarter.C3$PERCENT01_N > PER.NEU.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.08966746 0.91033254
table(Pc.by.quarter.C3$PERCENT01_N > PER.NEU.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 941 743
prop.table(table(Pc.by.quarter.C3$PERCENT01_N >PER.NEU.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.5587886 0.4412114
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C3_delaval.SCM_quarter <-LYM.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C3$TOTAL02_N > exp(optimal_lym_C3_delaval.SCM_quarter))
##
## FALSE TRUE
## 1204 480
prop.table(table(Pc.by.quarter.C3$TOTAL02_N > exp(optimal_lym_C3_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.7149644 0.2850356
# confidence intervals
table(Pc.by.quarter.C3$TOTAL02_N > exp(LYM.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1136 548
prop.table(table(Pc.by.quarter.C3$TOTAL02_N > exp(LYM.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.6745843 0.3254157
table(Pc.by.quarter.C3$TOTAL02_N > exp(LYM.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1278 406
prop.table(table(Pc.by.quarter.C3$TOTAL02_N >exp(LYM.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.7589074 0.2410926
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C3_delaval.SCM_quarter <-PER.LYM.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C3$PERCENT02_N > optimal_per_lym_C3_delaval.SCM_quarter)
##
## FALSE TRUE
## 463 1221
prop.table(table(Pc.by.quarter.C3$PERCENT02_N > optimal_per_lym_C3_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.2749406 0.7250594
# confidence intervals
table(Pc.by.quarter.C3$PERCENT02_N > PER.LYM.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 95 1589
prop.table(table(Pc.by.quarter.C3$PERCENT02_N > PER.LYM.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.0564133 0.9435867
table(Pc.by.quarter.C3$PERCENT02_N > PER.LYM.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 1018 666
prop.table(table(Pc.by.quarter.C3$PERCENT02_N >PER.LYM.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.6045131 0.3954869
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C3_delaval.SCM_quarter <- MAC.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C3$TOTAL03_N > exp(optimal_mac_C3_delaval.SCM_quarter))
##
## FALSE TRUE
## 1209 475
prop.table(table(Pc.by.quarter.C3$TOTAL03_N > exp(optimal_mac_C3_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.7179335 0.2820665
# confidence intervals
table(Pc.by.quarter.C3$TOTAL03_N > exp(MAC.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1057 627
prop.table(table(Pc.by.quarter.C3$TOTAL03_N > exp(MAC.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.6276722 0.3723278
table(Pc.by.quarter.C3$TOTAL03_N > exp(MAC.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1280 404
prop.table(table(Pc.by.quarter.C3$TOTAL03_N >exp(MAC.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.760095 0.239905
# Percent MAC
# optimal cut-off
optimal_per_mac_C3_delaval.SCM_quarter <- PER.MAC.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C3$PERCENT03_N > optimal_per_mac_C3_delaval.SCM_quarter)
##
## FALSE TRUE
## 1360 324
prop.table(table(Pc.by.quarter.C3$PERCENT03_N > optimal_per_mac_C3_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.807601 0.192399
# confidence intervals
table(Pc.by.quarter.C3$PERCENT03_N > PER.MAC.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 1050 634
prop.table(table(Pc.by.quarter.C3$PERCENT03_N > PER.MAC.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.6235154 0.3764846
table(Pc.by.quarter.C3$PERCENT03_N > PER.MAC.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 1484 200
prop.table(table(Pc.by.quarter.C3$PERCENT03_N > PER.MAC.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.8812352 0.1187648
# Set a seed for reproducibility
set.seed(123)
# SCC IMI cow
SCC.IMI <- cutpointr(Pc.by.cow.C5, log.SCC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(SCC.IMI)
## Method: maximize_metric
## Predictor: log.SCC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5467 417 309 108
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.804 1.1547 0.4317 0.2751 0.8796 0.8673 0.2978 85
## fn fp tn
## 224 13 95
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.386294 3.081738 3.737670 4.234107 4.454499 4.762174 7.297509
## 0 2.484907 3.232603 3.707399 4.151009 4.280960 4.579813 6.001713
## 1 1.386294 2.995732 3.761200 4.248495 4.515153 4.867534 7.514084
## Max. SD NAs
## 8.572249 1.1737622 0
## 8.203030 0.8937674 0
## 8.572249 1.2526175 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.74 4.04 4.71 4.80 4.74 4.85 4.99 6.31 0.26 0
## AUC_b 0.45 0.50 0.53 0.55 0.55 0.57 0.60 0.65 0.03 0
## AUC_oob 0.38 0.48 0.52 0.55 0.55 0.57 0.61 0.68 0.04 0
## sum_sens_spec_b 1.05 1.10 1.14 1.17 1.17 1.19 1.23 1.32 0.04 0
## sum_sens_spec_oob 0.82 0.97 1.07 1.12 1.11 1.15 1.21 1.34 0.07 0
## acc_b 0.29 0.39 0.42 0.44 0.46 0.47 0.61 0.68 0.06 0
## acc_oob 0.31 0.37 0.41 0.43 0.44 0.46 0.54 0.64 0.05 0
## sensitivity_b 0.11 0.22 0.26 0.29 0.32 0.33 0.64 0.79 0.11 0
## sensitivity_oob 0.09 0.20 0.25 0.28 0.31 0.32 0.59 0.75 0.11 0
## specificity_b 0.26 0.54 0.84 0.88 0.85 0.91 0.94 0.99 0.11 0
## specificity_oob 0.21 0.40 0.79 0.85 0.80 0.89 0.94 0.98 0.15 0
## cohens_kappa_b 0.03 0.06 0.09 0.11 0.11 0.12 0.16 0.26 0.03 0
## cohens_kappa_oob -0.15 -0.03 0.04 0.07 0.07 0.10 0.13 0.23 0.05 0
## ppv_b 0.73 0.80 0.84 0.87 0.87 0.89 0.92 0.97 0.04 0
## ppv_oob 0.63 0.72 0.79 0.83 0.83 0.87 0.92 0.97 0.06 0
## npv_b 0.22 0.26 0.29 0.30 0.30 0.32 0.35 0.40 0.03 0
## npv_oob 0.13 0.22 0.26 0.29 0.29 0.31 0.35 0.41 0.04 0
# ROC plot
plot(SCC.IMI)
# Youden index plot
plot_metric(SCC.IMI)
# NEU IMI cow
NEU.IMI <- cutpointr(Pc.by.cow.C5, log.TOTAL.NEU.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.IMI)
## Method: maximize_metric
## Predictor: log.TOTAL.NEU.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5369 419 311 108
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.2195 1.1457 0.4153 0.2476 0.8981 0.875 0.2931 77
## fn fp tn
## 234 11 97
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.386294 2.302585 2.890372 3.401197 3.680466 4.068990 6.305914
## 0 1.945910 2.335944 2.944439 3.258097 3.528510 3.789808 5.274794
## 1 1.386294 2.249905 2.890372 3.433987 3.733235 4.197174 6.455302
## Max. SD NAs
## 8.948976 1.267673 0
## 8.350902 1.070034 0
## 8.948976 1.326957 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.00 3.30 3.87 4.11 4.02 4.22 4.25 4.36 0.28 0
## AUC_b 0.44 0.49 0.52 0.54 0.54 0.56 0.59 0.65 0.03 0
## AUC_oob 0.41 0.47 0.51 0.54 0.54 0.56 0.60 0.66 0.04 0
## sum_sens_spec_b 1.03 1.10 1.13 1.16 1.16 1.19 1.23 1.29 0.04 0
## sum_sens_spec_oob 0.80 0.97 1.06 1.11 1.10 1.15 1.20 1.29 0.07 0
## acc_b 0.34 0.39 0.42 0.44 0.45 0.47 0.58 0.67 0.05 0
## acc_oob 0.30 0.36 0.40 0.42 0.43 0.45 0.53 0.61 0.05 0
## sensitivity_b 0.18 0.22 0.25 0.28 0.32 0.34 0.59 0.74 0.10 0
## sensitivity_oob 0.13 0.20 0.24 0.27 0.30 0.32 0.56 0.70 0.10 0
## specificity_b 0.34 0.57 0.83 0.88 0.84 0.91 0.94 0.98 0.10 0
## specificity_oob 0.18 0.46 0.76 0.84 0.80 0.89 0.94 1.00 0.14 0
## cohens_kappa_b 0.02 0.06 0.08 0.10 0.10 0.12 0.15 0.21 0.03 0
## cohens_kappa_oob -0.15 -0.02 0.03 0.06 0.06 0.09 0.12 0.18 0.04 0
## ppv_b 0.74 0.79 0.84 0.87 0.86 0.89 0.93 0.98 0.04 0
## ppv_oob 0.64 0.72 0.78 0.83 0.82 0.87 0.92 1.00 0.06 0
## npv_b 0.21 0.26 0.28 0.30 0.30 0.32 0.35 0.44 0.03 0
## npv_oob 0.14 0.22 0.26 0.28 0.28 0.31 0.34 0.40 0.04 0
# ROC plot
plot(NEU.IMI)
# Youden index plot
plot_metric(NEU.IMI)
# %NEU IMI cow
PER.NEU.IMI <- cutpointr(Pc.by.cow.C5, PERCENT.NEU.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.IMI)
## Method: maximize_metric
## Predictor: PERCENT.NEU.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5037 419 311 108
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 54.94 1.0687 0.5465 0.5595 0.5093 0.7665 0.2865
## tp fn fp tn
## 174 137 53 55
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 18.75 37.08 49.465 56.45 56.18427 64.360 73.096 86.73 11.04959 0
## 0 27.33 37.67 50.000 54.68 56.14639 65.805 72.730 81.25 10.97584 0
## 1 18.75 37.30 49.325 57.07 56.19743 64.185 73.160 86.73 11.09267 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 27.61 43.48 54.76 55.81 Inf 57.83 68.38 Inf NaN 0
## AUC_b 0.39 0.45 0.48 0.50 0.50 0.53 0.56 0.61 0.03 0
## AUC_oob 0.36 0.44 0.48 0.50 0.50 0.53 0.58 0.66 0.04 0
## sum_sens_spec_b 1.00 1.02 1.06 1.09 1.09 1.12 1.17 1.25 0.05 0
## sum_sens_spec_oob 0.77 0.89 0.96 1.00 1.00 1.04 1.11 1.22 0.06 0
## acc_b 0.21 0.33 0.51 0.55 0.53 0.58 0.72 0.79 0.11 0
## acc_oob 0.22 0.30 0.46 0.51 0.50 0.55 0.67 0.80 0.11 0
## sensitivity_b 0.00 0.14 0.47 0.55 0.52 0.59 0.89 1.00 0.22 0
## sensitivity_oob 0.00 0.11 0.43 0.52 0.49 0.57 0.87 1.00 0.22 0
## specificity_b 0.01 0.17 0.51 0.56 0.57 0.64 0.94 1.00 0.21 0
## specificity_oob 0.00 0.07 0.42 0.50 0.51 0.58 0.90 1.00 0.23 0
## cohens_kappa_b 0.00 0.02 0.04 0.07 0.07 0.10 0.14 0.21 0.04 0
## cohens_kappa_oob -0.19 -0.09 -0.03 0.00 0.00 0.03 0.08 0.18 0.05 0
## ppv_b 0.69 0.74 0.76 0.78 0.79 0.81 0.87 1.00 0.05 1
## ppv_oob 0.33 0.66 0.71 0.74 0.74 0.77 0.81 1.00 0.06 16
## npv_b 0.19 0.25 0.27 0.30 0.31 0.32 0.39 1.00 0.08 0
## npv_oob 0.00 0.16 0.23 0.26 0.25 0.28 0.33 1.00 0.07 5
# ROC plot
plot(PER.NEU.IMI)
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(PER.NEU.IMI)
# LYM IMI cow
LYM.IMI <- cutpointr(Pc.by.cow.C5, log.TOTAL.LYM.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.IMI)
## Method: maximize_metric
## Predictor: log.TOTAL.LYM.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5315 419 311 108
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.0445 1.1594 0.4344 0.2797 0.8796 0.87 0.2978 87
## fn fp tn
## 224 13 95
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 1.098612 1.94591 2.484907 2.640265 2.944439 5.162445 7.123673
## 0 0 1.386294 1.94591 2.397895 2.527277 2.833213 4.703667 6.562444
## 1 0 1.098612 1.94591 2.484907 2.679503 3.238486 5.176006 7.123673
## SD NAs
## 1.180885 0
## 1.034037 0
## 1.226891 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.08 2.94 3.00 3.04 3.03 3.14 3.14 3.43 0.11 0
## AUC_b 0.41 0.48 0.51 0.53 0.53 0.55 0.58 0.63 0.03 0
## AUC_oob 0.40 0.46 0.50 0.53 0.53 0.56 0.59 0.66 0.04 0
## sum_sens_spec_b 1.04 1.10 1.14 1.17 1.17 1.19 1.23 1.28 0.04 0
## sum_sens_spec_oob 0.80 1.02 1.10 1.14 1.13 1.17 1.23 1.30 0.06 0
## acc_b 0.37 0.40 0.42 0.44 0.44 0.46 0.49 0.66 0.03 0
## acc_oob 0.32 0.38 0.41 0.43 0.43 0.45 0.48 0.57 0.03 0
## sensitivity_b 0.18 0.24 0.27 0.29 0.29 0.31 0.35 0.77 0.05 0
## sensitivity_oob 0.16 0.22 0.26 0.28 0.28 0.31 0.35 0.68 0.05 0
## specificity_b 0.37 0.81 0.86 0.88 0.88 0.90 0.93 0.97 0.05 0
## specificity_oob 0.16 0.72 0.82 0.86 0.85 0.89 0.94 1.00 0.08 0
## cohens_kappa_b 0.02 0.06 0.09 0.10 0.10 0.12 0.15 0.19 0.03 0
## cohens_kappa_oob -0.16 0.01 0.06 0.08 0.08 0.11 0.14 0.20 0.04 0
## ppv_b 0.76 0.81 0.85 0.87 0.87 0.90 0.92 0.97 0.03 0
## ppv_oob 0.64 0.76 0.82 0.85 0.85 0.89 0.93 1.00 0.05 0
## npv_b 0.22 0.26 0.28 0.30 0.30 0.32 0.34 0.38 0.03 0
## npv_oob 0.16 0.23 0.27 0.29 0.29 0.31 0.34 0.43 0.03 0
# ROC plot
plot(LYM.IMI)
# Youden index plot
plot_metric(LYM.IMI)
# %LYM IMI cow
PER.LYM.IMI <- cutpointr(Pc.by.cow.C5, PERCENT.LYM.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.IMI)
## Method: maximize_metric
## Predictor: PERCENT.LYM.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5362 419 108 311
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 21.82 1.0924 0.5776 0.4815 0.6109 0.3006 0.7724 52
## fn fp tn
## 56 121 190
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 0.0 10.4470 15.7150 20.00 20.80084 25.250 34.2940 44.79 7.256602
## 0 6.9 10.3785 16.6175 21.29 21.41593 26.165 34.5185 38.60 6.990463
## 1 0.0 10.4700 15.3000 19.63 20.58723 24.415 34.1050 44.79 7.345701
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 6.90 15.29 16.11 19.92 19.92 21.82 28.36 36.17 4.03
## AUC_b 0.42 0.48 0.51 0.54 0.53 0.56 0.59 0.64 0.03
## AUC_oob 0.39 0.47 0.51 0.54 0.54 0.57 0.61 0.67 0.04
## sum_sens_spec_b 1.01 1.05 1.09 1.12 1.12 1.15 1.20 1.27 0.04
## sum_sens_spec_oob 0.80 0.92 0.98 1.03 1.03 1.07 1.13 1.25 0.07
## acc_b 0.21 0.38 0.44 0.55 0.53 0.60 0.69 0.77 0.10
## acc_oob 0.19 0.35 0.42 0.51 0.50 0.57 0.65 0.79 0.09
## sensitivity_b 0.05 0.25 0.50 0.60 0.61 0.80 0.88 1.00 0.19
## sensitivity_oob 0.00 0.16 0.42 0.53 0.54 0.72 0.85 1.00 0.21
## specificity_b 0.01 0.23 0.31 0.53 0.51 0.62 0.85 0.98 0.19
## specificity_oob 0.01 0.21 0.29 0.51 0.48 0.61 0.82 0.98 0.19
## cohens_kappa_b 0.00 0.04 0.06 0.09 0.09 0.12 0.16 0.25 0.04
## cohens_kappa_oob -0.17 -0.07 -0.01 0.02 0.02 0.05 0.10 0.20 0.05
## ppv_b 0.20 0.25 0.28 0.31 0.31 0.33 0.38 0.65 0.04
## ppv_oob 0.00 0.19 0.24 0.27 0.27 0.29 0.34 0.45 0.05
## npv_b 0.71 0.75 0.77 0.80 0.80 0.82 0.87 1.00 0.04
## npv_oob 0.50 0.68 0.73 0.76 0.76 0.79 0.83 1.00 0.05
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.LYM.IMI)
# Youden index plot
plot_metric(PER.LYM.IMI)
# MAC IMI cow
MAC.IMI <- cutpointr(Pc.by.cow.C5, log.TOTAL.MAC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.IMI)
## Method: maximize_metric
## Predictor: log.TOTAL.MAC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5733 419 311 108
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 2.3026 1.1323 0.5847 0.6045 0.5278 0.7866 0.3167
## tp fn fp tn
## 188 123 51 57
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 1.098612 1.945910 2.397895 2.672747 3.178054 5.651974 7.611842
## 0 0 1.098612 1.791759 2.197225 2.471720 2.833213 5.630198 7.611842
## 1 0 1.098612 1.945910 2.484907 2.742557 3.258097 5.579908 7.431892
## SD NAs
## 1.335131 0
## 1.300397 0
## 1.341996 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 1.10 2.20 2.30 2.56 2.63 2.89 3.22 4.13 0.41 0
## AUC_b 0.47 0.52 0.55 0.57 0.57 0.59 0.63 0.68 0.03 0
## AUC_oob 0.42 0.51 0.55 0.57 0.57 0.60 0.64 0.69 0.04 0
## sum_sens_spec_b 1.02 1.09 1.13 1.16 1.16 1.19 1.24 1.32 0.05 0
## sum_sens_spec_oob 0.88 0.97 1.04 1.08 1.08 1.13 1.18 1.32 0.06 0
## acc_b 0.32 0.41 0.47 0.54 0.54 0.60 0.64 0.75 0.08 0
## acc_oob 0.30 0.38 0.45 0.51 0.51 0.57 0.62 0.74 0.08 0
## sensitivity_b 0.12 0.26 0.35 0.49 0.49 0.62 0.69 0.97 0.15 0
## sensitivity_oob 0.08 0.24 0.34 0.47 0.47 0.61 0.68 0.97 0.15 0
## specificity_b 0.06 0.46 0.55 0.68 0.67 0.80 0.88 0.98 0.15 0
## specificity_oob 0.02 0.36 0.49 0.60 0.61 0.75 0.86 0.97 0.17 0
## cohens_kappa_b 0.02 0.06 0.09 0.12 0.12 0.15 0.19 0.26 0.04 0
## cohens_kappa_oob -0.13 -0.02 0.03 0.06 0.06 0.09 0.14 0.23 0.05 0
## ppv_b 0.71 0.76 0.79 0.82 0.82 0.84 0.88 0.96 0.04 0
## ppv_oob 0.62 0.72 0.75 0.78 0.78 0.81 0.86 0.95 0.04 0
## npv_b 0.22 0.26 0.29 0.32 0.32 0.34 0.38 0.59 0.04 0
## npv_oob 0.06 0.22 0.26 0.29 0.29 0.31 0.35 0.47 0.04 0
# ROC plot
plot(MAC.IMI)
# Youden index plot
plot_metric(MAC.IMI)
# %MAC Major IMI cow
PER.MAC.IMI<- cutpointr(Pc.by.cow.C5, PERCENT.MAC.CO.COW, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.IMI)
## Method: maximize_metric
## Predictor: PERCENT.MAC.CO.COW
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5265 419 311 108
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 15.56 1.0895 0.6158 0.6913 0.3981 0.7679 0.3094
## tp fn fp tn
## 215 96 65 43
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 2.00 8.100 14.210 21.210 23.01516 29.8950 45.593 71.88 11.66827 0
## 0 2.13 6.292 13.405 20.125 22.43806 29.6325 45.375 59.38 12.13685 0
## 1 2.00 8.305 14.355 21.670 23.21556 30.8800 44.820 71.88 11.51440 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 5.56 6.38 14.29 15.65 19.13 22.92 29.90 48.65 6.64
## AUC_b 0.41 0.47 0.50 0.53 0.52 0.55 0.58 0.63 0.03
## AUC_oob 0.36 0.46 0.50 0.53 0.53 0.56 0.60 0.68 0.04
## sum_sens_spec_b 1.00 1.04 1.08 1.11 1.12 1.15 1.19 1.29 0.04
## sum_sens_spec_oob 0.73 0.92 0.99 1.03 1.03 1.07 1.14 1.25 0.06
## acc_b 0.24 0.41 0.52 0.60 0.58 0.65 0.74 0.82 0.10
## acc_oob 0.21 0.37 0.48 0.56 0.55 0.62 0.71 0.82 0.10
## sensitivity_b 0.04 0.27 0.48 0.66 0.61 0.75 0.98 1.00 0.20
## sensitivity_oob 0.02 0.24 0.45 0.62 0.58 0.73 0.97 1.00 0.20
## specificity_b 0.02 0.10 0.37 0.49 0.51 0.65 0.83 0.99 0.20
## specificity_oob 0.00 0.06 0.30 0.42 0.44 0.59 0.79 0.98 0.21
## cohens_kappa_b 0.00 0.04 0.07 0.10 0.10 0.12 0.17 0.28 0.04
## cohens_kappa_oob -0.20 -0.07 -0.01 0.02 0.02 0.06 0.11 0.24 0.05
## ppv_b 0.70 0.74 0.77 0.79 0.79 0.81 0.84 0.96 0.03
## ppv_oob 0.50 0.69 0.73 0.75 0.75 0.78 0.81 0.91 0.04
## npv_b 0.21 0.26 0.29 0.32 0.34 0.35 0.50 1.00 0.10
## npv_oob 0.00 0.19 0.24 0.27 0.28 0.31 0.38 1.00 0.09
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 2
# ROC plot
plot(PER.MAC.IMI)
# Youden index plot
plot_metric(PER.MAC.IMI)
# Summary of results when using C5 and IMI as reference
print(c("Optimal SCC:", exp(SCC.IMI$optimal_cutpoint), SCC.IMI$sensitivity, SCC.IMI$specificity, SCC.IMI$ppv, SCC.IMI$npv, SCC.IMI$AUC))
## sensitivity specificity
## "Optimal SCC:" "122" "0.275080906148867" "0.87962962962963"
##
## "0.86734693877551" "0.297805642633229" "0.546745774901115"
print(c("Optimal n NEU:", exp(NEU.IMI$optimal_cutpoint), NEU.IMI$sensitivity, NEU.IMI$specificity, NEU.IMI$ppv, NEU.IMI$npv, NEU.IMI$AUC))
## sensitivity specificity
## "Optimal n NEU:" "68" "0.247588424437299" "0.898148148148148"
##
## "0.875" "0.293051359516616" "0.53685840181017"
print(c("Optimal %NEU:", PER.NEU.IMI$optimal_cutpoint, PER.NEU.IMI$sensitivity, PER.NEU.IMI$specificity, PER.NEU.IMI$ppv, PER.NEU.IMI$npv, PER.NEU.IMI$AUC))
## sensitivity specificity
## "Optimal %NEU:" "54.94" "0.559485530546624" "0.509259259259259"
##
## "0.766519823788546" "0.286458333333333" "0.50372156722639"
print(c("Optimal n LYM:", exp(LYM.IMI$optimal_cutpoint), LYM.IMI$sensitivity, LYM.IMI$specificity, LYM.IMI$ppv, LYM.IMI$npv, LYM.IMI$AUC))
## sensitivity specificity
## "Optimal n LYM:" "21" "0.279742765273312" "0.87962962962963"
##
## "0.87" "0.297805642633229" "0.531499345004168"
print(c("Optimal %LYM:", PER.LYM.IMI$optimal_cutpoint, PER.LYM.IMI$sensitivity, PER.LYM.IMI$specificity, PER.LYM.IMI$ppv, PER.LYM.IMI$npv, PER.LYM.IMI$AUC))
## sensitivity specificity
## "Optimal %LYM:" "21.82" "0.481481481481481" "0.610932475884244"
##
## "0.300578034682081" "0.772357723577236" "0.536173633440514"
print(c("Optimal n MAC:", exp(MAC.IMI$optimal_cutpoint), MAC.IMI$sensitivity, MAC.IMI$specificity, MAC.IMI$ppv, MAC.IMI$npv, MAC.IMI$AUC))
## sensitivity specificity
## "Optimal n MAC:" "10" "0.604501607717042" "0.527777777777778"
##
## "0.786610878661088" "0.316666666666667" "0.573329760628796"
print(c("Optimal %MAC:", PER.MAC.IMI$optimal_cutpoint, PER.MAC.IMI$sensitivity, PER.MAC.IMI$specificity, PER.MAC.IMI$ppv, PER.MAC.IMI$npv, PER.MAC.IMI$AUC))
## sensitivity specificity
## "Optimal %MAC:" "15.56" "0.691318327974277" "0.398148148148148"
##
## "0.767857142857143" "0.309352517985612" "0.526482672382994"
# CI using bootstrapping
# SCC.IMI
SCC.IMI_optimal_cutpoint <- boot_ci(SCC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
SCC.IMI_lower_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(SCC.IMI_lower_ci)
## [1] 56
SCC.IMI_upper_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(SCC.IMI_upper_ci)
## [1] 154.0497
boot_ci(SCC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.199
## 2 0.975 0.672
boot_ci(SCC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.5
## 2 0.975 0.946
boot_ci(SCC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.781
## 2 0.975 0.935
boot_ci(SCC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.251
## 2 0.975 0.365
boot_ci(SCC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.486
## 2 0.975 0.604
# NEU.IMI
NEU.IMI_optimal_cutpoint <- boot_ci(NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.IMI_lower_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.IMI_lower_ci)
## [1] 27
NEU.IMI_upper_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.IMI_upper_ci)
## [1] 76
boot_ci(NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.212
## 2 0.975 0.608
boot_ci(NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.545
## 2 0.975 0.946
boot_ci(NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.777
## 2 0.975 0.938
boot_ci(NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.251
## 2 0.975 0.361
boot_ci(NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.479
## 2 0.975 0.594
# PER.NEU.IMI
PER.NEU.IMI_optimal_cutpoint <- boot_ci(PER.NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 32.5
## 2 0.975 73.1
PER.NEU.IMI_lower_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.IMI_upper_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0502
## 2 0.975 0.987
boot_ci(PER.NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0535
## 2 0.975 0.982
boot_ci(PER.NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.726
## 2 0.975 0.917
boot_ci(PER.NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.239
## 2 0.975 0.5
boot_ci(PER.NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.438
## 2 0.975 0.568
# LYM.IMI
LYM.IMI_optimal_cutpoint <- boot_ci(LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.IMI_lower_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.IMI_lower_ci)
## [1] 16
LYM.IMI_upper_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.IMI_upper_ci)
## [1] 23
boot_ci(LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.231
## 2 0.975 0.400
boot_ci(LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.768
## 2 0.975 0.941
boot_ci(LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.803
## 2 0.975 0.934
boot_ci(LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.25
## 2 0.975 0.351
boot_ci(LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.475
## 2 0.975 0.591
# PER.LYM.IMI
PER.LYM.IMI_optimal_cutpoint <- boot_ci(PER.LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 15.3
## 2 0.975 29.1
PER.LYM.IMI_lower_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.IMI_upper_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.186
## 2 0.975 0.918
boot_ci(PER.LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.208
## 2 0.975 0.894
boot_ci(PER.LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.245
## 2 0.975 0.406
boot_ci(PER.LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.738
## 2 0.975 0.889
boot_ci(PER.LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.471
## 2 0.975 0.599
# MAC.IMI
MAC.IMI_optimal_cutpoint <- boot_ci(MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.IMI_lower_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.IMI_lower_ci)
## [1] 9
MAC.IMI_upper_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.IMI_upper_ci)
## [1] 29
boot_ci(MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.237
## 2 0.975 0.711
boot_ci(MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.425
## 2 0.975 0.903
boot_ci(MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.752
## 2 0.975 0.894
boot_ci(MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.256
## 2 0.975 0.392
boot_ci(MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.510
## 2 0.975 0.634
# PER.MAC.IMI
PER.MAC.IMI_optimal_cutpoint <- boot_ci(PER.MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 6.36
## 2 0.975 30
PER.MAC.IMI_lower_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.IMI_upper_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.254
## 2 0.975 0.987
boot_ci(PER.MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0654
## 2 0.975 0.856
boot_ci(PER.MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.731
## 2 0.975 0.853
boot_ci(PER.MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.254
## 2 0.975 0.667
boot_ci(PER.MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.458
## 2 0.975 0.587
# Prevalence
# True prevalence
table(Pc.by.cow.C5$IMI.cow)
##
## 0 1
## 108 313
prop.table(table(Pc.by.cow.C5$IMI.cow))
##
## 0 1
## 0.2565321 0.7434679
#Apparent prevalence
# ---- SCC ----
# optimal cut-off
optimal_scc_C5_IMI_cow <- SCC.IMI$optimal_cutpoint
table(Pc.by.cow.C5$SCC.CO.COW > exp(optimal_scc_C5_IMI_cow))
##
## FALSE TRUE
## 322 98
prop.table(table(Pc.by.cow.C5$SCC.CO.COW > exp(optimal_scc_C5_IMI_cow)))
##
## FALSE TRUE
## 0.7666667 0.2333333
# confidence intervals
table(Pc.by.cow.C5$SCC.CO.COW > exp(SCC.IMI_lower_ci))
##
## FALSE TRUE
## 168 252
prop.table(table(Pc.by.cow.C5$SCC.CO.COW > exp(SCC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.4 0.6
table(Pc.by.cow.C5$SCC.CO.COW > exp(SCC.IMI_upper_ci))
##
## FALSE TRUE
## 342 78
prop.table(table(Pc.by.cow.C5$SCC.CO.COW >exp(SCC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.8142857 0.1857143
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C5_IMI_cow <- NEU.IMI$optimal_cutpoint
table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(optimal_neu_C5_IMI_cow))
##
## FALSE TRUE
## 334 88
prop.table(table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(optimal_neu_C5_IMI_cow)))
##
## FALSE TRUE
## 0.7914692 0.2085308
# confidence intervals
table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(NEU.IMI_lower_ci))
##
## FALSE TRUE
## 196 226
prop.table(table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(NEU.IMI_lower_ci)))
##
## FALSE TRUE
## 0.464455 0.535545
table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(NEU.IMI_upper_ci))
##
## FALSE TRUE
## 343 79
prop.table(table(Pc.by.cow.C5$TOTAL.NEU.CO.COW >exp(NEU.IMI_upper_ci)))
##
## FALSE TRUE
## 0.8127962 0.1872038
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C5_IMI_cow <-PER.NEU.IMI$optimal_cutpoint
table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > optimal_per_neu_C5_IMI_cow)
##
## FALSE TRUE
## 194 228
prop.table(table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > optimal_per_neu_C5_IMI_cow))
##
## FALSE TRUE
## 0.4597156 0.5402844
# confidence intervals
table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > PER.NEU.IMI_lower_ci)
##
## FALSE TRUE
## 9 413
prop.table(table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > PER.NEU.IMI_lower_ci))
##
## FALSE TRUE
## 0.02132701 0.97867299
table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > PER.NEU.IMI_upper_ci)
##
## FALSE TRUE
## 401 21
prop.table(table(Pc.by.cow.C5$PERCENT.NEU.CO.COW >PER.NEU.IMI_upper_ci))
##
## FALSE TRUE
## 0.95023697 0.04976303
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C5_IMI_cow <-LYM.IMI$optimal_cutpoint
table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(optimal_lym_C5_IMI_cow))
##
## FALSE TRUE
## 324 98
prop.table(table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(optimal_lym_C5_IMI_cow)))
##
## FALSE TRUE
## 0.7677725 0.2322275
# confidence intervals
table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(LYM.IMI_lower_ci))
##
## FALSE TRUE
## 267 155
prop.table(table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(LYM.IMI_lower_ci)))
##
## FALSE TRUE
## 0.6327014 0.3672986
table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(LYM.IMI_upper_ci))
##
## FALSE TRUE
## 330 92
prop.table(table(Pc.by.cow.C5$TOTAL.LYM.CO.COW >exp(LYM.IMI_upper_ci)))
##
## FALSE TRUE
## 0.7819905 0.2180095
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C5_IMI_cow <-PER.LYM.IMI$optimal_cutpoint
table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > optimal_per_lym_C5_IMI_cow)
##
## FALSE TRUE
## 250 172
prop.table(table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > optimal_per_lym_C5_IMI_cow))
##
## FALSE TRUE
## 0.5924171 0.4075829
# confidence intervals
table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > PER.LYM.IMI_lower_ci)
##
## FALSE TRUE
## 97 325
prop.table(table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > PER.LYM.IMI_lower_ci))
##
## FALSE TRUE
## 0.2298578 0.7701422
table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > PER.LYM.IMI_upper_ci)
##
## FALSE TRUE
## 368 54
prop.table(table(Pc.by.cow.C5$PERCENT.LYM.CO.COW >PER.LYM.IMI_upper_ci))
##
## FALSE TRUE
## 0.8720379 0.1279621
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C5_IMI_cow <- MAC.IMI$optimal_cutpoint
table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(optimal_mac_C5_IMI_cow))
##
## FALSE TRUE
## 193 229
prop.table(table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(optimal_mac_C5_IMI_cow)))
##
## FALSE TRUE
## 0.457346 0.542654
# confidence intervals
table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(MAC.IMI_lower_ci))
##
## FALSE TRUE
## 181 241
prop.table(table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(MAC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.42891 0.57109
table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(MAC.IMI_upper_ci))
##
## FALSE TRUE
## 333 89
prop.table(table(Pc.by.cow.C5$TOTAL.MAC.CO.COW >exp(MAC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.7890995 0.2109005
# Percent MAC
# optimal cut-off
optimal_per_mac_C5_IMI_cow <- PER.MAC.IMI$optimal_cutpoint
table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > optimal_per_mac_C5_IMI_cow)
##
## FALSE TRUE
## 140 282
prop.table(table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > optimal_per_mac_C5_IMI_cow))
##
## FALSE TRUE
## 0.3317536 0.6682464
# confidence intervals
table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > PER.MAC.IMI_lower_ci)
##
## FALSE TRUE
## 13 409
prop.table(table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > PER.MAC.IMI_lower_ci))
##
## FALSE TRUE
## 0.03080569 0.96919431
table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > PER.MAC.IMI_upper_ci)
##
## FALSE TRUE
## 318 104
prop.table(table(Pc.by.cow.C5$PERCENT.MAC.CO.COW >PER.MAC.IMI_upper_ci))
##
## FALSE TRUE
## 0.7535545 0.2464455
# Set a seed for reproducibility
set.seed(123)
# Delaval SCM (SCC>200.000) reference
# n NEU SCM COW
NEU.SCM <- cutpointr(Pc.by.cow.C5, log.TOTAL.NEU.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.NEU.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9726 420 63 357
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.4427 1.8973 0.9571 0.9365 0.9608 0.8082 0.9885 59
## fn fp tn
## 4 14 343
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.386294 2.297317 2.890372 3.401197 3.674843 4.064717 6.232366
## 0 1.386294 2.079442 2.833213 3.218876 3.276409 3.761200 4.343805
## 1 2.833213 4.330004 4.979177 5.762051 5.932633 6.931957 8.484060
## Max. SD NAs
## 8.948976 1.2673930 0
## 8.350902 0.7143865 0
## 8.948976 1.3531688 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 4.06 4.32 4.38 4.44 4.43 4.47 4.58 4.82 0.09 0
## AUC_b 0.91 0.95 0.96 0.97 0.97 0.98 0.99 1.00 0.01 0
## AUC_oob 0.91 0.94 0.96 0.97 0.97 0.99 1.00 1.00 0.02 0
## sum_sens_spec_b 1.77 1.85 1.88 1.90 1.90 1.92 1.95 1.98 0.03 0
## sum_sens_spec_oob 1.50 1.77 1.83 1.87 1.87 1.91 1.96 1.99 0.06 0
## acc_b 0.87 0.93 0.95 0.96 0.96 0.97 0.98 1.00 0.01 0
## acc_oob 0.84 0.92 0.94 0.95 0.95 0.96 0.97 0.99 0.02 0
## sensitivity_b 0.83 0.89 0.93 0.95 0.94 0.97 0.99 1.00 0.03 0
## sensitivity_oob 0.52 0.80 0.88 0.92 0.91 0.96 1.00 1.00 0.06 0
## specificity_b 0.86 0.93 0.95 0.96 0.96 0.97 0.98 1.00 0.02 0
## specificity_oob 0.81 0.91 0.94 0.96 0.95 0.97 0.98 1.00 0.02 0
## cohens_kappa_b 0.57 0.76 0.81 0.84 0.84 0.87 0.91 0.98 0.05 0
## cohens_kappa_oob 0.54 0.71 0.77 0.81 0.81 0.85 0.90 0.97 0.06 0
## ppv_b 0.48 0.69 0.76 0.81 0.80 0.85 0.90 0.99 0.07 0
## ppv_oob 0.44 0.65 0.73 0.79 0.79 0.85 0.91 1.00 0.08 0
## npv_b 0.97 0.98 0.99 0.99 0.99 0.99 1.00 1.00 0.01 0
## npv_oob 0.92 0.96 0.98 0.98 0.98 0.99 1.00 1.00 0.01 0
# ROC plot
plot(NEU.SCM)
# Youden index plot
plot_metric(NEU.SCM)
# %NEU SCM COW
PER.NEU.SCM <- cutpointr(Pc.by.cow.C5, PERCENT.NEU.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.SCM)
## Method: maximize_metric
## Predictor: PERCENT.NEU.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5992 420 63 357
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 62.21 1.226 0.6976 0.4921 0.7339 0.246 0.8912 31
## fn fp tn
## 32 95 262
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 18.75 37.090 49.425 56.475 56.18600 64.355 73.088 86.73 11.07392 0
## 0 18.75 37.500 49.450 55.560 55.67866 62.790 72.444 86.73 10.69669 0
## 1 27.33 34.938 49.960 61.370 59.06095 69.330 75.299 81.93 12.72340 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 43.23 56.32 61.14 62.21 63.44 66.75 68.95 72.27 3.77
## AUC_b 0.43 0.53 0.57 0.60 0.60 0.63 0.67 0.75 0.04
## AUC_oob 0.36 0.50 0.56 0.60 0.60 0.64 0.69 0.80 0.06
## sum_sens_spec_b 1.03 1.15 1.20 1.25 1.25 1.29 1.35 1.52 0.06
## sum_sens_spec_oob 0.80 1.01 1.10 1.16 1.15 1.21 1.30 1.46 0.09
## acc_b 0.23 0.57 0.68 0.71 0.72 0.79 0.83 0.87 0.08
## acc_oob 0.22 0.54 0.65 0.69 0.70 0.76 0.82 0.87 0.08
## sensitivity_b 0.13 0.28 0.39 0.50 0.49 0.57 0.69 0.98 0.13
## sensitivity_oob 0.00 0.19 0.30 0.41 0.41 0.50 0.62 0.87 0.14
## specificity_b 0.12 0.55 0.70 0.74 0.76 0.86 0.92 0.96 0.11
## specificity_oob 0.11 0.53 0.68 0.74 0.75 0.85 0.91 0.97 0.12
## cohens_kappa_b 0.03 0.10 0.15 0.19 0.19 0.23 0.29 0.39 0.06
## cohens_kappa_oob -0.13 0.01 0.07 0.12 0.12 0.17 0.25 0.36 0.07
## ppv_b 0.14 0.19 0.23 0.27 0.28 0.32 0.43 0.53 0.07
## ppv_oob 0.00 0.14 0.19 0.23 0.24 0.27 0.37 0.56 0.07
## npv_b 0.82 0.86 0.88 0.89 0.89 0.91 0.93 0.98 0.02
## npv_oob 0.76 0.83 0.86 0.88 0.88 0.89 0.92 0.97 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.SCM)
# Youden index plot
plot_metric(PER.NEU.SCM)
# Lym
LYM.SCM <- cutpointr(Pc.by.cow.C5, log.TOTAL.LYM.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.LYM.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9769 420 63 357
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.1355 1.873 0.9143 0.9683 0.9048 0.6421 0.9938 61
## fn fp tn
## 2 34 323
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.098612 1.945910 2.484907 2.633699 2.944439 5.136961
## 0 0.000000 1.098612 1.791759 2.302585 2.273239 2.772589 3.401197
## 1 2.564949 3.258097 3.939267 4.442651 4.676303 5.280659 6.418765
## Max. SD NAs
## 7.123673 1.1794695 0
## 6.562444 0.7513396 0
## 7.123673 1.0827760 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.14 3.14 3.14 3.26 3.26 3.26 3.56 3.87 0.16 0
## AUC_b 0.94 0.96 0.97 0.98 0.98 0.98 0.99 1.00 0.01 0
## AUC_oob 0.93 0.96 0.97 0.98 0.98 0.99 0.99 1.00 0.01 0
## sum_sens_spec_b 1.77 1.83 1.86 1.88 1.88 1.90 1.92 1.97 0.03 0
## sum_sens_spec_oob 1.57 1.74 1.81 1.85 1.84 1.88 1.92 1.96 0.06 0
## acc_b 0.87 0.90 0.91 0.92 0.93 0.94 0.97 0.98 0.02 0
## acc_oob 0.85 0.89 0.90 0.92 0.92 0.93 0.95 0.98 0.02 0
## sensitivity_b 0.82 0.90 0.94 0.96 0.96 0.98 1.00 1.00 0.03 0
## sensitivity_oob 0.60 0.78 0.89 0.95 0.92 0.96 1.00 1.00 0.07 0
## specificity_b 0.86 0.89 0.90 0.92 0.92 0.94 0.98 0.99 0.03 0
## specificity_oob 0.84 0.87 0.90 0.92 0.92 0.94 0.98 1.00 0.03 0
## cohens_kappa_b 0.58 0.67 0.71 0.75 0.76 0.80 0.87 0.93 0.06 0
## cohens_kappa_oob 0.52 0.63 0.69 0.73 0.73 0.77 0.83 0.93 0.06 0
## ppv_b 0.49 0.58 0.63 0.68 0.69 0.74 0.87 0.95 0.09 0
## ppv_oob 0.43 0.54 0.61 0.67 0.68 0.73 0.86 1.00 0.10 0
## npv_b 0.97 0.98 0.99 0.99 0.99 1.00 1.00 1.00 0.01 0
## npv_oob 0.93 0.96 0.98 0.99 0.99 0.99 1.00 1.00 0.01 0
# ROC plot
plot(LYM.SCM)
# Youden index plot
plot_metric(LYM.SCM)
# %LYM SCM COW
PER.LYM.SCM <- cutpointr(Pc.by.cow.C5, PERCENT.LYM.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.SCM)
## Method: maximize_metric
## Predictor: PERCENT.LYM.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.6827 420 357 63
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 21.79 1.394 0.5405 0.4734 0.9206 0.9713 0.2358
## tp fn fp tn
## 169 188 5 58
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.00 10.4485 15.7175 19.96 20.77726 25.0575 34.292 44.79 7.242575 0
## 0 0.00 10.5220 16.4600 21.05 21.43543 26.3200 34.620 44.79 7.438397 0
## 1 6.55 9.1440 14.8000 17.02 17.04762 19.9550 25.020 27.78 4.490512 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 16.67 21.05 21.79 21.79 21.63 21.82 21.88 26.32 0.75
## AUC_b 0.57 0.63 0.66 0.68 0.68 0.70 0.73 0.78 0.03
## AUC_oob 0.54 0.61 0.65 0.68 0.68 0.71 0.75 0.83 0.04
## sum_sens_spec_b 1.21 1.33 1.37 1.40 1.40 1.43 1.46 1.53 0.04
## sum_sens_spec_oob 0.95 1.20 1.32 1.37 1.36 1.42 1.48 1.61 0.08
## acc_b 0.33 0.50 0.53 0.55 0.55 0.56 0.59 0.75 0.04
## acc_oob 0.36 0.48 0.51 0.54 0.54 0.56 0.60 0.71 0.04
## sensitivity_b 0.24 0.43 0.46 0.48 0.48 0.50 0.54 0.78 0.05
## sensitivity_oob 0.25 0.41 0.45 0.47 0.48 0.50 0.55 0.78 0.05
## specificity_b 0.57 0.85 0.90 0.92 0.92 0.95 0.97 1.00 0.05
## specificity_oob 0.26 0.70 0.86 0.90 0.88 0.95 1.00 1.00 0.11
## cohens_kappa_b 0.07 0.14 0.17 0.18 0.18 0.20 0.23 0.33 0.03
## cohens_kappa_oob -0.03 0.09 0.14 0.16 0.16 0.19 0.23 0.33 0.04
## ppv_b 0.89 0.94 0.96 0.97 0.97 0.98 0.99 1.00 0.01
## ppv_oob 0.81 0.90 0.95 0.97 0.96 0.98 1.00 1.00 0.03
## npv_b 0.14 0.19 0.22 0.24 0.24 0.26 0.29 0.40 0.03
## npv_oob 0.10 0.17 0.20 0.23 0.23 0.25 0.29 0.35 0.04
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.LYM.SCM)
# Youden index plot
plot_metric(PER.LYM.SCM)
# MAC SCM COW
MAC.SCM <- cutpointr(Pc.by.cow.C5, log.TOTAL.MAC.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.SCM)
## Method: maximize_metric
## Predictor: log.TOTAL.MAC.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9595 420 63 357
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.2958 1.8067 0.9024 0.9048 0.902 0.6196 0.9817 57
## fn fp tn
## 6 35 322
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.098612 1.945910 2.397895 2.668517 3.178054 5.527306
## 0 0.000000 1.098612 1.791759 2.302585 2.271053 2.772589 3.668625
## 1 2.079442 2.949568 3.960405 4.859812 4.920813 6.041444 7.142157
## Max. SD NAs
## 7.611842 1.3313114 0
## 7.611842 0.8558791 0
## 7.431892 1.3067079 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.89 2.89 3.30 3.52 3.51 3.76 3.89 4.14 0.29 0
## AUC_b 0.90 0.93 0.95 0.96 0.96 0.97 0.98 1.00 0.01 0
## AUC_oob 0.89 0.93 0.95 0.96 0.96 0.98 0.99 1.00 0.02 0
## sum_sens_spec_b 1.69 1.76 1.80 1.82 1.82 1.85 1.89 1.94 0.04 0
## sum_sens_spec_oob 1.30 1.65 1.72 1.77 1.76 1.81 1.86 1.94 0.07 0
## acc_b 0.79 0.85 0.90 0.93 0.92 0.95 0.96 0.98 0.03 0
## acc_oob 0.76 0.83 0.89 0.91 0.91 0.93 0.95 0.98 0.04 0
## sensitivity_b 0.73 0.82 0.86 0.90 0.90 0.93 0.97 1.00 0.05 0
## sensitivity_oob 0.32 0.71 0.79 0.85 0.85 0.91 0.96 1.00 0.08 0
## specificity_b 0.75 0.83 0.90 0.93 0.92 0.96 0.98 1.00 0.04 0
## specificity_oob 0.71 0.81 0.89 0.93 0.92 0.96 0.98 0.99 0.05 0
## cohens_kappa_b 0.42 0.57 0.68 0.74 0.73 0.80 0.85 0.91 0.09 0
## cohens_kappa_oob 0.35 0.51 0.63 0.69 0.68 0.75 0.82 0.90 0.09 0
## ppv_b 0.36 0.49 0.62 0.70 0.70 0.80 0.87 0.98 0.12 0
## ppv_oob 0.30 0.46 0.58 0.67 0.67 0.77 0.87 0.96 0.13 0
## npv_b 0.95 0.97 0.98 0.98 0.98 0.99 0.99 1.00 0.01 0
## npv_oob 0.90 0.94 0.96 0.97 0.97 0.98 0.99 1.00 0.01 0
# ROC plot
plot(MAC.SCM)
# Youden index plot
plot_metric(MAC.SCM)
# %MAC SCM COW
PER.MAC.SCM <- cutpointr(Pc.by.cow.C5, PERCENT.MAC.CO.COW, delaval.SCM.CO.COW,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.SCM)
## Method: maximize_metric
## Predictor: PERCENT.MAC.CO.COW
## Outcome: delaval.SCM.CO.COW
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.4753 420 357 63
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 21.67 1.0299 0.4976 0.4902 0.5397 0.8578 0.1574
## tp fn fp tn
## 175 182 29 34
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 2.00 8.120 14.25 21.19 23.03700 29.9175 45.5565 71.88 11.66521 0
## 0 2.00 8.000 14.13 21.21 22.88622 29.7900 44.5460 71.88 11.62919 0
## 1 5.94 8.862 14.83 21.16 23.89143 32.1950 45.3430 52.07 11.92548 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 6.00 9.16 12.88 21.38 23.24 24.76 52.15 54.24 12.74
## AUC_b 0.34 0.41 0.45 0.48 0.48 0.50 0.54 0.60 0.04
## AUC_oob 0.26 0.39 0.44 0.47 0.47 0.51 0.57 0.64 0.05
## sum_sens_spec_b 0.82 1.02 1.05 1.08 1.08 1.11 1.16 1.27 0.05
## sum_sens_spec_oob 0.62 0.83 0.91 0.96 0.95 1.00 1.04 1.17 0.07
## acc_b 0.13 0.17 0.45 0.53 0.53 0.74 0.81 0.89 0.20
## acc_oob 0.12 0.16 0.41 0.49 0.50 0.70 0.79 0.90 0.20
## sensitivity_b 0.01 0.03 0.42 0.51 0.53 0.82 0.93 0.99 0.28
## sensitivity_oob 0.00 0.02 0.39 0.49 0.51 0.80 0.92 0.99 0.29
## specificity_b 0.03 0.12 0.27 0.59 0.55 0.69 1.00 1.00 0.28
## specificity_oob 0.00 0.04 0.15 0.45 0.44 0.58 1.00 1.00 0.30
## cohens_kappa_b -0.10 0.01 0.03 0.05 0.05 0.07 0.12 0.22 0.03
## cohens_kappa_oob -0.18 -0.11 -0.06 -0.02 -0.03 0.00 0.03 0.13 0.04
## ppv_b 0.71 0.84 0.86 0.88 0.89 0.90 1.00 1.00 0.05
## ppv_oob 0.40 0.75 0.81 0.84 0.84 0.86 1.00 1.00 0.07
## npv_b 0.08 0.14 0.16 0.18 0.19 0.20 0.27 0.50 0.05
## npv_oob 0.00 0.05 0.11 0.13 0.13 0.16 0.19 0.27 0.04
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 14
## 0
## 0
# ROC plot
plot(PER.MAC.SCM)
# Youden index plot
plot_metric(PER.MAC.SCM)
# Summary of results when using SCM as reference
print(c("Optimal n NEU:", exp(NEU.SCM$optimal_cutpoint), NEU.SCM$sensitivity, NEU.SCM$specificity, NEU.SCM$ppv, NEU.SCM$npv, NEU.SCM$AUC))
## sensitivity specificity
## "Optimal n NEU:" "85" "0.936507936507937" "0.96078431372549"
##
## "0.808219178082192" "0.988472622478386" "0.972633497843582"
print(c("Optimal %NEU:", PER.NEU.SCM$optimal_cutpoint, PER.NEU.SCM$sensitivity, PER.NEU.SCM$specificity, PER.NEU.SCM$ppv, PER.NEU.SCM$npv, PER.NEU.SCM$AUC))
## sensitivity specificity
## "Optimal %NEU:" "62.21" "0.492063492063492" "0.733893557422969"
##
## "0.246031746031746" "0.891156462585034" "0.599217464763683"
print(c("Optimal n LYM:", exp(LYM.SCM$optimal_cutpoint), LYM.SCM$sensitivity, LYM.SCM$specificity, LYM.SCM$ppv, LYM.SCM$npv, LYM.SCM$AUC))
## sensitivity specificity
## "Optimal n LYM:" "23" "0.968253968253968" "0.904761904761905"
##
## "0.642105263157895" "0.993846153846154" "0.976901871859855"
print(c("Optimal %LYM:", PER.LYM.SCM$optimal_cutpoint, PER.LYM.SCM$sensitivity, PER.LYM.SCM$specificity, PER.LYM.SCM$ppv, PER.LYM.SCM$npv, PER.LYM.SCM$AUC))
## sensitivity specificity
## "Optimal %LYM:" "21.79" "0.473389355742297" "0.920634920634921"
##
## "0.971264367816092" "0.235772357723577" "0.682739762571695"
print(c("Optimal n MAC:", exp(MAC.SCM$optimal_cutpoint), MAC.SCM$sensitivity, MAC.SCM$specificity, MAC.SCM$ppv, MAC.SCM$npv, MAC.SCM$AUC))
## sensitivity specificity
## "Optimal n MAC:" "27" "0.904761904761905" "0.901960784313726"
##
## "0.619565217391304" "0.981707317073171" "0.959539371304077"
print(c("Optimal %MAC:", PER.MAC.SCM$optimal_cutpoint, PER.MAC.SCM$sensitivity, PER.MAC.SCM$specificity, PER.MAC.SCM$ppv, PER.MAC.SCM$npv, PER.MAC.SCM$AUC))
## sensitivity specificity
## "Optimal %MAC:" "21.67" "0.490196078431373" "0.53968253968254"
##
## "0.857843137254902" "0.157407407407407" "0.475301231603753"
# CI using bootstrapping
# NEU.SCM
NEU.SCM_optimal_cutpoint <- boot_ci(NEU.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.SCM_lower_ci <- subset(NEU.SCM_optimal_cutpoint, NEU.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.SCM_lower_ci)
## [1] 75
NEU.SCM_upper_ci <- subset(NEU.SCM_optimal_cutpoint, NEU.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.SCM_upper_ci)
## [1] 98
boot_ci(NEU.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.881
## 2 0.975 1
boot_ci(NEU.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.923
## 2 0.975 0.986
boot_ci(NEU.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.667
## 2 0.975 0.922
boot_ci(NEU.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.977
## 2 0.975 1
boot_ci(NEU.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.941
## 2 0.975 0.995
# PER.NEU.SCM
PER.NEU.SCM_optimal_cutpoint <- boot_ci(PER.NEU.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 56.3
## 2 0.975 69.2
PER.NEU.SCM_lower_ci <- subset(PER.NEU.SCM_optimal_cutpoint, PER.NEU.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.SCM_upper_ci <- subset(PER.NEU.SCM_optimal_cutpoint, PER.NEU.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.254
## 2 0.975 0.721
boot_ci(PER.NEU.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.528
## 2 0.975 0.928
boot_ci(PER.NEU.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.184
## 2 0.975 0.452
boot_ci(PER.NEU.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.858
## 2 0.975 0.933
boot_ci(PER.NEU.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.512
## 2 0.975 0.686
# LYM.SCM
LYM.SCM_optimal_cutpoint <- boot_ci(LYM.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.SCM_lower_ci <- subset(LYM.SCM_optimal_cutpoint, LYM.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.SCM_lower_ci)
## [1] 23
LYM.SCM_upper_ci <- subset(LYM.SCM_optimal_cutpoint, LYM.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.SCM_upper_ci)
## [1] 35
boot_ci(LYM.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.884
## 2 0.975 1
boot_ci(LYM.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.883
## 2 0.975 0.980
boot_ci(LYM.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.563
## 2 0.975 0.885
boot_ci(LYM.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.979
## 2 0.975 1
boot_ci(LYM.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.959
## 2 0.975 0.990
# PER.LYM.SCM
PER.LYM.SCM_optimal_cutpoint <- boot_ci(PER.LYM.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 19.0
## 2 0.975 21.9
PER.LYM.SCM_lower_ci <- subset(PER.LYM.SCM_optimal_cutpoint, PER.LYM.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.SCM_upper_ci <- subset(PER.LYM.SCM_optimal_cutpoint, PER.LYM.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.423
## 2 0.975 0.646
boot_ci(PER.LYM.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.768
## 2 0.975 0.983
boot_ci(PER.LYM.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.937
## 2 0.975 0.994
boot_ci(PER.LYM.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.185
## 2 0.975 0.302
boot_ci(PER.LYM.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.621
## 2 0.975 0.740
# MAC.SCM
MAC.SCM_optimal_cutpoint <- boot_ci(MAC.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.SCM_lower_ci <- subset(MAC.SCM_optimal_cutpoint, MAC.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.SCM_lower_ci)
## [1] 18
MAC.SCM_upper_ci <- subset(MAC.SCM_optimal_cutpoint, MAC.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.SCM_upper_ci)
## [1] 50
boot_ci(MAC.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.806
## 2 0.975 0.984
boot_ci(MAC.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.802
## 2 0.975 0.981
boot_ci(MAC.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.455
## 2 0.975 0.892
boot_ci(MAC.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.963
## 2 0.975 0.997
boot_ci(MAC.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.929
## 2 0.975 0.985
# PER.MAC.SCM
PER.MAC.SCM_optimal_cutpoint <- boot_ci(PER.MAC.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 9.09
## 2 0.975 53.2
PER.MAC.SCM_lower_ci <- subset(PER.MAC.SCM_optimal_cutpoint, PER.MAC.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.SCM_upper_ci <- subset(PER.MAC.SCM_optimal_cutpoint, PER.MAC.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0197
## 2 0.975 0.948
boot_ci(PER.MAC.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0986
## 2 0.975 1
boot_ci(PER.MAC.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.833
## 2 0.975 1
boot_ci(PER.MAC.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.129
## 2 0.975 0.3
boot_ci(PER.MAC.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.397
## 2 0.975 0.555
# Prevalence
# True prevalence
table(Pc.by.cow.C5$delaval.SCM.CO.COW)
##
## 0 1
## 357 63
prop.table(table(Pc.by.cow.C5$delaval.SCM.CO.COW))
##
## 0 1
## 0.85 0.15
#Apparent prevalence
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C5_SCM_cow <- NEU.SCM$optimal_cutpoint
table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(optimal_neu_C5_SCM_cow))
##
## FALSE TRUE
## 349 73
prop.table(table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(optimal_neu_C5_SCM_cow)))
##
## FALSE TRUE
## 0.8270142 0.1729858
# confidence intervals
table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(NEU.SCM_lower_ci))
##
## FALSE TRUE
## 338 84
prop.table(table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(NEU.SCM_lower_ci)))
##
## FALSE TRUE
## 0.8009479 0.1990521
table(Pc.by.cow.C5$TOTAL.NEU.CO.COW > exp(NEU.SCM_upper_ci))
##
## FALSE TRUE
## 359 63
prop.table(table(Pc.by.cow.C5$TOTAL.NEU.CO.COW >exp(NEU.SCM_upper_ci)))
##
## FALSE TRUE
## 0.8507109 0.1492891
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C5_SCM_cow <-PER.NEU.SCM$optimal_cutpoint
table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > optimal_per_neu_C5_SCM_cow)
##
## FALSE TRUE
## 297 125
prop.table(table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > optimal_per_neu_C5_SCM_cow))
##
## FALSE TRUE
## 0.7037915 0.2962085
# confidence intervals
table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > PER.NEU.SCM_lower_ci)
##
## FALSE TRUE
## 210 212
prop.table(table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > PER.NEU.SCM_lower_ci))
##
## FALSE TRUE
## 0.4976303 0.5023697
table(Pc.by.cow.C5$PERCENT.NEU.CO.COW > PER.NEU.SCM_upper_ci)
##
## FALSE TRUE
## 373 49
prop.table(table(Pc.by.cow.C5$PERCENT.NEU.CO.COW >PER.NEU.SCM_upper_ci))
##
## FALSE TRUE
## 0.8838863 0.1161137
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C5_SCM_cow <-LYM.SCM$optimal_cutpoint
table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(optimal_lym_C5_SCM_cow))
##
## FALSE TRUE
## 330 92
prop.table(table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(optimal_lym_C5_SCM_cow)))
##
## FALSE TRUE
## 0.7819905 0.2180095
# confidence intervals
table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(LYM.SCM_lower_ci))
##
## FALSE TRUE
## 330 92
prop.table(table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(LYM.SCM_lower_ci)))
##
## FALSE TRUE
## 0.7819905 0.2180095
table(Pc.by.cow.C5$TOTAL.LYM.CO.COW > exp(LYM.SCM_upper_ci))
##
## FALSE TRUE
## 355 67
prop.table(table(Pc.by.cow.C5$TOTAL.LYM.CO.COW >exp(LYM.SCM_upper_ci)))
##
## FALSE TRUE
## 0.8412322 0.1587678
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C5_SCM_cow <-PER.LYM.SCM$optimal_cutpoint
table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > optimal_per_lym_C5_SCM_cow)
##
## FALSE TRUE
## 248 174
prop.table(table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > optimal_per_lym_C5_SCM_cow))
##
## FALSE TRUE
## 0.5876777 0.4123223
# confidence intervals
table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > PER.LYM.SCM_lower_ci)
##
## FALSE TRUE
## 187 235
prop.table(table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > PER.LYM.SCM_lower_ci))
##
## FALSE TRUE
## 0.443128 0.556872
table(Pc.by.cow.C5$PERCENT.LYM.CO.COW > PER.LYM.SCM_upper_ci)
##
## FALSE TRUE
## 252 170
prop.table(table(Pc.by.cow.C5$PERCENT.LYM.CO.COW >PER.LYM.SCM_upper_ci))
##
## FALSE TRUE
## 0.5971564 0.4028436
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C5_SCM_cow <- MAC.SCM$optimal_cutpoint
table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(optimal_mac_C5_SCM_cow))
##
## FALSE TRUE
## 331 91
prop.table(table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(optimal_mac_C5_SCM_cow)))
##
## FALSE TRUE
## 0.7843602 0.2156398
# confidence intervals
table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(MAC.SCM_lower_ci))
##
## FALSE TRUE
## 288 134
prop.table(table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(MAC.SCM_lower_ci)))
##
## FALSE TRUE
## 0.6824645 0.3175355
table(Pc.by.cow.C5$TOTAL.MAC.CO.COW > exp(MAC.SCM_upper_ci))
##
## FALSE TRUE
## 362 60
prop.table(table(Pc.by.cow.C5$TOTAL.MAC.CO.COW >exp(MAC.SCM_upper_ci)))
##
## FALSE TRUE
## 0.8578199 0.1421801
# Percent MAC
# optimal cut-off
optimal_per_mac_C5_SCM_cow <- PER.MAC.SCM$optimal_cutpoint
table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > optimal_per_mac_C5_SCM_cow)
##
## FALSE TRUE
## 218 204
prop.table(table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > optimal_per_mac_C5_SCM_cow))
##
## FALSE TRUE
## 0.5165877 0.4834123
# confidence intervals
table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > PER.MAC.SCM_lower_ci)
##
## FALSE TRUE
## 31 391
prop.table(table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > PER.MAC.SCM_lower_ci))
##
## FALSE TRUE
## 0.07345972 0.92654028
table(Pc.by.cow.C5$PERCENT.MAC.CO.COW > PER.MAC.SCM_upper_ci)
##
## FALSE TRUE
## 416 6
prop.table(table(Pc.by.cow.C5$PERCENT.MAC.CO.COW >PER.MAC.SCM_upper_ci))
##
## FALSE TRUE
## 0.98578199 0.01421801
# Set a seed for reproducibility
set.seed(123)
# IMI QUARTER referent
# SCC IMI quarter
SCC.IMI <- cutpointr(Pc.by.quarter.C5, log.SCC, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(SCC.IMI)
## Method: maximize_metric
## Predictor: log.SCC
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5151 1552 538 1014
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 4.9628 1.0725 0.6392 0.2007 0.8718 0.4538 0.6728
## tp fn fp tn
## 108 430 130 884
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.386294 2.772589 3.526361 4.043051 4.160545 4.590018 6.203706
## 0 1.386294 2.811995 3.526361 4.043051 4.113878 4.553877 5.666724
## 1 1.791759 2.708050 3.526361 4.051747 4.248501 4.781162 6.899994
## Max. SD NAs
## 8.522181 1.0520387 0
## 8.488176 0.9515683 0
## 8.522181 1.2152049 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.53 4.47 4.76 4.84 4.87 4.96 5.29 7.52 0.27 0
## AUC_b 0.47 0.49 0.50 0.52 0.52 0.53 0.54 0.56 0.02 0
## AUC_oob 0.43 0.48 0.50 0.52 0.52 0.53 0.55 0.58 0.02 0
## sum_sens_spec_b 1.02 1.05 1.07 1.08 1.08 1.09 1.11 1.14 0.02 0
## sum_sens_spec_oob 0.92 1.01 1.04 1.06 1.05 1.07 1.10 1.15 0.03 0
## acc_b 0.45 0.60 0.62 0.63 0.63 0.64 0.66 0.70 0.02 0
## acc_oob 0.40 0.57 0.61 0.62 0.62 0.64 0.66 0.69 0.03 0
## sensitivity_b 0.05 0.14 0.21 0.23 0.24 0.27 0.36 0.78 0.06 0
## sensitivity_oob 0.04 0.12 0.19 0.22 0.22 0.25 0.33 0.74 0.06 0
## specificity_b 0.27 0.72 0.82 0.85 0.84 0.87 0.93 0.99 0.06 0
## specificity_oob 0.21 0.70 0.81 0.84 0.83 0.87 0.92 0.99 0.06 0
## cohens_kappa_b 0.03 0.06 0.08 0.09 0.09 0.11 0.13 0.16 0.02 0
## cohens_kappa_oob -0.07 0.01 0.04 0.06 0.06 0.08 0.11 0.17 0.03 0
## ppv_b 0.36 0.40 0.42 0.45 0.45 0.47 0.52 0.74 0.04 0
## ppv_oob 0.28 0.35 0.39 0.42 0.42 0.45 0.50 0.74 0.05 0
## npv_b 0.63 0.65 0.67 0.68 0.68 0.69 0.70 0.72 0.01 0
## npv_oob 0.58 0.64 0.66 0.67 0.67 0.68 0.70 0.72 0.02 0
# ROC plot
plot(SCC.IMI)
# Youden index plot
plot_metric(SCC.IMI)
# NEU IMI quarter
NEU.IMI <- cutpointr(Pc.by.quarter.C5, log.Neu, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.IMI)
## Method: maximize_metric
## Predictor: log.Neu
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5251 1556 541 1015
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.9318 1.08 0.6234 0.2662 0.8138 0.4324 0.6754
## tp fn fp tn
## 144 397 189 826
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.098612 2.197225 2.833213 3.258097 3.435124 3.806662 5.330222
## 0 1.098612 2.197225 2.833213 3.218876 3.369005 3.761200 4.996741
## 1 1.098612 2.197225 2.833213 3.295837 3.559175 3.970292 6.226537
## Max. SD NAs
## 10.174773 1.1008755 0
## 9.036463 0.9590292 0
## 10.174773 1.3187892 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.56 3.69 3.93 3.93 4.04 4.11 4.71 6.04 0.31 0
## AUC_b 0.47 0.50 0.51 0.52 0.52 0.54 0.55 0.59 0.02 0
## AUC_oob 0.46 0.49 0.51 0.53 0.53 0.54 0.56 0.59 0.02 0
## sum_sens_spec_b 1.02 1.05 1.07 1.08 1.08 1.10 1.12 1.16 0.02 0
## sum_sens_spec_oob 0.92 1.01 1.04 1.06 1.06 1.08 1.11 1.15 0.03 0
## acc_b 0.41 0.60 0.62 0.63 0.63 0.64 0.66 0.69 0.02 0
## acc_oob 0.36 0.57 0.61 0.62 0.62 0.64 0.66 0.68 0.03 0
## sensitivity_b 0.05 0.13 0.23 0.26 0.25 0.28 0.36 0.90 0.07 0
## sensitivity_oob 0.04 0.11 0.21 0.24 0.24 0.27 0.32 0.84 0.07 0
## specificity_b 0.15 0.73 0.81 0.83 0.83 0.86 0.94 0.98 0.07 0
## specificity_oob 0.12 0.71 0.80 0.82 0.82 0.85 0.94 0.99 0.07 0
## cohens_kappa_b 0.03 0.06 0.08 0.09 0.09 0.11 0.13 0.17 0.02 0
## cohens_kappa_oob -0.07 0.01 0.05 0.07 0.07 0.09 0.12 0.16 0.03 0
## ppv_b 0.35 0.40 0.43 0.45 0.45 0.47 0.52 0.69 0.04 0
## ppv_oob 0.29 0.35 0.40 0.42 0.43 0.45 0.50 0.75 0.05 0
## npv_b 0.63 0.65 0.67 0.68 0.68 0.69 0.70 0.74 0.01 0
## npv_oob 0.58 0.64 0.66 0.67 0.67 0.68 0.70 0.74 0.02 0
# ROC plot
plot(NEU.IMI)
# Youden index plot
plot_metric(NEU.IMI)
# %NEU IMI quarter
PER.NEU.IMI <- cutpointr(Pc.by.quarter.C5, PERCENT01_N, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.IMI)
## Method: maximize_metric
## Predictor: PERCENT01_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5189 1556 541 1015
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 60.51 1.0438 0.5694 0.366 0.6778 0.3771 0.6673
## tp fn fp tn
## 198 343 327 688
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 13.79 38.3825 50.000 56.285 56.30482 63.27 73.7025 89.55 10.65339
## 0 21.89 38.1740 49.415 56.100 56.04310 62.96 72.8050 89.55 10.54335
## 1 13.79 38.6100 50.000 56.760 56.79584 64.00 74.3600 88.07 10.84965
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 28.05 48.48 51.79 60.34 58.11 60.83 68.03 76.06 6.96
## AUC_b 0.47 0.49 0.51 0.52 0.52 0.53 0.54 0.57 0.02
## AUC_oob 0.44 0.48 0.50 0.52 0.52 0.53 0.55 0.59 0.02
## sum_sens_spec_b 1.01 1.03 1.04 1.06 1.06 1.07 1.09 1.14 0.02
## sum_sens_spec_oob 0.91 0.96 0.99 1.00 1.01 1.02 1.05 1.12 0.03
## acc_b 0.34 0.43 0.48 0.57 0.54 0.60 0.64 0.68 0.07
## acc_oob 0.34 0.40 0.45 0.55 0.52 0.58 0.62 0.67 0.07
## sensitivity_b 0.04 0.16 0.35 0.40 0.48 0.71 0.83 1.00 0.23
## sensitivity_oob 0.02 0.12 0.30 0.37 0.45 0.67 0.80 0.99 0.23
## specificity_b 0.01 0.23 0.35 0.67 0.58 0.71 0.89 0.98 0.23
## specificity_oob 0.00 0.21 0.33 0.66 0.56 0.70 0.87 0.97 0.23
## cohens_kappa_b 0.00 0.02 0.04 0.06 0.06 0.07 0.09 0.14 0.02
## cohens_kappa_oob -0.08 -0.04 -0.01 0.00 0.01 0.02 0.05 0.12 0.03
## ppv_b 0.32 0.35 0.37 0.38 0.39 0.40 0.45 0.62 0.03
## ppv_oob 0.19 0.31 0.33 0.35 0.35 0.37 0.40 0.54 0.03
## npv_b 0.63 0.65 0.67 0.68 0.68 0.69 0.72 1.00 0.02
## npv_oob 0.33 0.61 0.64 0.66 0.65 0.67 0.69 0.74 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.IMI)
# Youden index plot
plot_metric(PER.NEU.IMI)
# LYM IMI quarter
LYM.IMI <- cutpointr(Pc.by.quarter.C5, log.Lym, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.IMI)
## Method: maximize_metric
## Predictor: log.Lym
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5289 1556 541 1015
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.2189 1.0822 0.6395 0.2181 0.864 0.4609 0.6746
## tp fn fp tn
## 118 423 138 877
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 1.098612 1.791759 2.302585 2.436436 2.890372 4.330733 8.165932
## 0 0 1.098612 1.791759 2.302585 2.380298 2.833213 4.012739 7.264730
## 1 0 1.098612 1.791759 2.397895 2.541760 3.044522 5.003946 8.165932
## SD NAs
## 1.0779589 0
## 0.9744082 0
## 1.2434561 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 2.20 2.48 2.77 3.22 3.06 3.22 3.30 4.87 0.29 0
## AUC_b 0.48 0.50 0.52 0.53 0.53 0.54 0.55 0.58 0.02 0
## AUC_oob 0.46 0.50 0.51 0.53 0.53 0.54 0.56 0.60 0.02 0
## sum_sens_spec_b 1.02 1.05 1.07 1.09 1.09 1.10 1.12 1.16 0.02 0
## sum_sens_spec_oob 0.94 1.00 1.04 1.06 1.06 1.09 1.11 1.17 0.03 0
## acc_b 0.49 0.57 0.61 0.63 0.62 0.65 0.66 0.68 0.03 0
## acc_oob 0.44 0.53 0.59 0.63 0.61 0.64 0.66 0.70 0.04 0
## sensitivity_b 0.07 0.19 0.22 0.24 0.28 0.35 0.47 0.67 0.10 0
## sensitivity_oob 0.04 0.17 0.21 0.23 0.26 0.31 0.44 0.65 0.09 0
## specificity_b 0.41 0.62 0.74 0.86 0.81 0.87 0.88 0.98 0.10 0
## specificity_oob 0.34 0.59 0.72 0.85 0.80 0.87 0.89 0.98 0.10 0
## cohens_kappa_b 0.02 0.06 0.08 0.09 0.10 0.11 0.13 0.17 0.02 0
## cohens_kappa_oob -0.05 0.00 0.04 0.07 0.07 0.10 0.13 0.19 0.04 0
## ppv_b 0.35 0.38 0.42 0.45 0.45 0.48 0.51 0.68 0.04 0
## ppv_oob 0.29 0.34 0.39 0.43 0.43 0.46 0.51 0.57 0.05 0
## npv_b 0.63 0.66 0.67 0.68 0.68 0.69 0.70 0.73 0.01 0
## npv_oob 0.59 0.64 0.66 0.67 0.67 0.68 0.70 0.73 0.02 0
# ROC plot
plot(LYM.IMI)
# Youden index plot
plot_metric(LYM.IMI)
# %LYM IMI quarter
PER.LYM.IMI <- cutpointr(Pc.by.quarter.C5, PERCENT02_N, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.IMI)
## Method: maximize_metric
## Predictor: PERCENT02_N
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5 1556 541 1015
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 22.12 1.035 0.5276 0.4843 0.5507 0.3649 0.6671
## tp fn fp tn
## 262 279 456 559
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.00 9.8375 16.1525 21.325 21.92774 27.0925 36.640 61.54 8.136529 0
## 0 4.17 10.0700 16.2650 21.170 21.98306 27.1800 36.642 61.54 8.071498 0
## 1 0.00 9.1500 16.0000 21.670 21.82396 27.0300 36.170 50.82 8.263679 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 7.90 19.72 22.12 22.92 Inf 25.00 36.92 Inf NaN 0
## AUC_b 0.44 0.47 0.49 0.50 0.50 0.51 0.53 0.56 0.02 0
## AUC_oob 0.43 0.47 0.49 0.50 0.50 0.51 0.53 0.56 0.02 0
## sum_sens_spec_b 1.00 1.01 1.03 1.05 1.05 1.06 1.09 1.14 0.02 0
## sum_sens_spec_oob 0.89 0.95 0.99 1.01 1.01 1.03 1.06 1.11 0.03 0
## acc_b 0.35 0.49 0.53 0.55 0.55 0.57 0.63 0.68 0.04 0
## acc_oob 0.33 0.47 0.51 0.53 0.53 0.55 0.62 0.68 0.04 0
## sensitivity_b 0.00 0.06 0.37 0.46 0.44 0.51 0.61 0.98 0.14 0
## sensitivity_oob 0.00 0.04 0.34 0.43 0.41 0.48 0.58 0.96 0.14 0
## specificity_b 0.02 0.44 0.55 0.60 0.61 0.69 0.96 1.00 0.14 0
## specificity_oob 0.02 0.41 0.53 0.58 0.59 0.67 0.95 1.00 0.14 0
## cohens_kappa_b 0.00 0.01 0.03 0.04 0.05 0.06 0.08 0.13 0.02 0
## cohens_kappa_oob -0.12 -0.04 -0.01 0.01 0.01 0.03 0.05 0.10 0.03 0
## ppv_b 0.32 0.35 0.36 0.38 0.38 0.39 0.42 1.00 0.04 2
## ppv_oob 0.00 0.31 0.33 0.35 0.35 0.37 0.39 0.54 0.04 7
## npv_b 0.62 0.64 0.66 0.67 0.67 0.68 0.70 0.76 0.02 0
## npv_oob 0.41 0.62 0.64 0.65 0.65 0.67 0.69 0.74 0.02 0
# ROC plot
plot(PER.LYM.IMI)
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_density()`).
# Youden index plot
plot_metric(PER.LYM.IMI)
# MAC IMI quarter
MAC.IMI <- cutpointr(Pc.by.quarter.C5, log.Mac, IMI,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.IMI)
## Method: maximize_metric
## Predictor: log.Mac
## Outcome: IMI
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5176 1556 541 1015
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.4657 1.057 0.6433 0.1516 0.9054 0.4607 0.6669 82
## fn fp tn
## 459 96 919
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max.
## Overall 0 0.6931472 1.609438 2.197225 2.351310 2.787745 4.521789 9.127176
## 0 0 1.0986123 1.609438 2.197225 2.310454 2.772589 4.334655 8.196988
## 1 0 0.6931472 1.609438 2.302585 2.427963 2.944439 4.962845 9.127176
## SD NAs
## 1.208201 0
## 1.093028 0
## 1.396821 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 1.95 2.40 2.71 3.04 3.05 3.47 3.53 7.46 0.44 0
## AUC_b 0.47 0.49 0.51 0.52 0.52 0.53 0.54 0.58 0.02 0
## AUC_oob 0.43 0.48 0.50 0.52 0.52 0.53 0.55 0.58 0.02 0
## sum_sens_spec_b 1.01 1.04 1.06 1.07 1.07 1.08 1.10 1.13 0.02 0
## sum_sens_spec_oob 0.89 0.98 1.01 1.04 1.03 1.05 1.08 1.13 0.03 0
## acc_b 0.47 0.54 0.60 0.63 0.62 0.64 0.66 0.68 0.04 0
## acc_oob 0.42 0.51 0.58 0.61 0.60 0.63 0.66 0.68 0.04 0
## sensitivity_b 0.02 0.13 0.17 0.24 0.27 0.34 0.51 0.72 0.12 0
## sensitivity_oob 0.00 0.12 0.15 0.21 0.24 0.30 0.47 0.65 0.11 0
## specificity_b 0.33 0.57 0.73 0.83 0.80 0.90 0.92 1.00 0.12 0
## specificity_oob 0.31 0.54 0.72 0.82 0.79 0.90 0.92 1.00 0.12 0
## cohens_kappa_b 0.02 0.04 0.06 0.08 0.08 0.09 0.11 0.14 0.02 0
## cohens_kappa_oob -0.10 -0.02 0.02 0.04 0.04 0.06 0.09 0.15 0.03 0
## ppv_b 0.33 0.37 0.40 0.43 0.44 0.46 0.51 0.86 0.05 0
## ppv_oob 0.00 0.33 0.36 0.39 0.40 0.43 0.49 0.89 0.05 0
## npv_b 0.63 0.65 0.66 0.67 0.67 0.68 0.70 0.72 0.01 0
## npv_oob 0.60 0.63 0.65 0.66 0.66 0.67 0.69 0.72 0.02 0
# ROC plot
plot(MAC.IMI)
# Youden index plot
plot_metric(MAC.IMI)
# %MAC Major IMI cow
PER.MAC.IMI<- cutpointr(Pc.by.quarter.C5, PERCENT03_N, IMI.cow,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.IMI)
## Method: maximize_metric
## Predictor: PERCENT03_N
## Outcome: IMI.cow
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5237 1635 417 1218
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 26.92 1.0492 0.6171 0.3357 0.7135 0.2863 0.7583
## tp fn fp tn
## 140 277 349 869
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.00 6.4200 13.0400 20.0 21.77527 28.615 43.270 69.57 11.52476 0
## 0 2.16 7.5400 13.7900 20.5 22.43103 29.670 43.568 60.39 11.35891 0
## 1 0.00 6.2365 12.7675 20.0 21.55076 28.330 42.860 69.57 11.57708 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 5.83 8.74 11.76 20.17 20.04 27.08 30.92 41.94 8.60
## AUC_b 0.47 0.50 0.51 0.52 0.52 0.53 0.55 0.58 0.02
## AUC_oob 0.45 0.49 0.51 0.52 0.52 0.54 0.56 0.59 0.02
## sum_sens_spec_b 1.01 1.04 1.05 1.07 1.07 1.08 1.10 1.14 0.02
## sum_sens_spec_oob 0.84 0.96 0.99 1.01 1.01 1.03 1.06 1.11 0.03
## acc_b 0.28 0.32 0.38 0.52 0.51 0.63 0.68 0.74 0.13
## acc_oob 0.26 0.31 0.36 0.49 0.49 0.61 0.66 0.74 0.13
## sensitivity_b 0.07 0.24 0.34 0.56 0.58 0.84 0.95 0.99 0.27
## sensitivity_oob 0.04 0.18 0.29 0.48 0.54 0.81 0.93 0.97 0.27
## specificity_b 0.04 0.11 0.22 0.51 0.49 0.73 0.82 0.96 0.27
## specificity_oob 0.04 0.10 0.21 0.49 0.47 0.72 0.82 0.95 0.27
## cohens_kappa_b 0.01 0.02 0.04 0.05 0.05 0.07 0.09 0.14 0.02
## cohens_kappa_oob -0.13 -0.04 -0.01 0.01 0.01 0.02 0.05 0.10 0.02
## ppv_b 0.24 0.25 0.27 0.29 0.29 0.31 0.33 0.44 0.03
## ppv_oob 0.17 0.22 0.25 0.26 0.26 0.27 0.30 0.35 0.02
## npv_b 0.73 0.75 0.76 0.78 0.79 0.81 0.86 0.92 0.03
## npv_oob 0.66 0.72 0.74 0.75 0.76 0.77 0.82 0.91 0.03
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.MAC.IMI)
# Youden index plot
plot_metric(PER.MAC.IMI)
# Summary of results when using C5 and IMI as the reference
print(c("Optimal SCC:", exp(SCC.IMI$optimal_cutpoint), SCC.IMI$sensitivity, SCC.IMI$specificity, SCC.IMI$ppv, SCC.IMI$npv, SCC.IMI$AUC))
## sensitivity specificity
## "Optimal SCC:" "143" "0.200743494423792" "0.871794871794872"
##
## "0.453781512605042" "0.672754946727549" "0.515092606849827"
print(c("Optimal n NEU:", exp(NEU.IMI$optimal_cutpoint), NEU.IMI$sensitivity, NEU.IMI$specificity, NEU.IMI$ppv, NEU.IMI$npv, NEU.IMI$AUC))
## sensitivity specificity
## "Optimal n NEU:" "51" "0.266173752310536" "0.813793103448276"
##
## "0.432432432432432" "0.675388389206868" "0.525104941587828"
print(c("Optimal %NEU:", PER.NEU.IMI$optimal_cutpoint, PER.NEU.IMI$sensitivity, PER.NEU.IMI$specificity, PER.NEU.IMI$ppv, PER.NEU.IMI$npv, PER.NEU.IMI$AUC))
## sensitivity specificity
## "Optimal %NEU:" "60.51" "0.365988909426987" "0.677832512315271"
##
## "0.377142857142857" "0.667313288069835" "0.518874006355681"
print(c("Optimal n LYM:", exp(LYM.IMI$optimal_cutpoint), LYM.IMI$sensitivity, LYM.IMI$specificity, LYM.IMI$ppv, LYM.IMI$npv, LYM.IMI$AUC))
## sensitivity specificity
## "Optimal n LYM:" "25" "0.2181146025878" "0.864039408866995"
##
## "0.4609375" "0.674615384615385" "0.528903781539386"
print(c("Optimal %LYM:", PER.LYM.IMI$optimal_cutpoint, PER.LYM.IMI$sensitivity, PER.LYM.IMI$specificity, PER.LYM.IMI$ppv, PER.LYM.IMI$npv, PER.LYM.IMI$AUC))
## sensitivity specificity
## "Optimal %LYM:" "22.12" "0.484288354898336" "0.550738916256158"
##
## "0.364902506963788" "0.667064439140811" "0.499978146654162"
print(c("Optimal n MAC:", exp(MAC.IMI$optimal_cutpoint), MAC.IMI$sensitivity, MAC.IMI$specificity, MAC.IMI$ppv, MAC.IMI$npv, MAC.IMI$AUC))
## sensitivity specificity
## "Optimal n MAC:" "32" "0.151571164510166" "0.905418719211823"
##
## "0.460674157303371" "0.666908563134978" "0.517645666208354"
print(c("Optimal %MAC:", PER.MAC.IMI$optimal_cutpoint, PER.MAC.IMI$sensitivity, PER.MAC.IMI$specificity, PER.MAC.IMI$ppv, PER.MAC.IMI$npv, PER.MAC.IMI$AUC))
## sensitivity specificity
## "Optimal %MAC:" "26.92" "0.335731414868106" "0.713464696223317"
##
## "0.286298568507157" "0.758289703315881" "0.523704189357873"
# Bootstrap confidence intervals
# SCC.IMI
SCC.IMI_optimal_cutpoint <- boot_ci(SCC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
SCC.IMI_lower_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(SCC.IMI_lower_ci)
## [1] 86
SCC.IMI_upper_ci <- subset(SCC.IMI_optimal_cutpoint, SCC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(SCC.IMI_upper_ci)
## [1] 247
boot_ci(SCC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.110
## 2 0.975 0.381
boot_ci(SCC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.707
## 2 0.975 0.950
boot_ci(SCC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.387
## 2 0.975 0.540
boot_ci(SCC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.650
## 2 0.975 0.703
boot_ci(SCC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.484
## 2 0.975 0.545
# NEU.IMI
NEU.IMI_optimal_cutpoint <- boot_ci(NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.IMI_lower_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.IMI_lower_ci)
## [1] 34
NEU.IMI_upper_ci <- subset(NEU.IMI_optimal_cutpoint, NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.IMI_upper_ci)
## [1] 183
boot_ci(NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.102
## 2 0.975 0.416
boot_ci(NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.672
## 2 0.975 0.954
boot_ci(NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.388
## 2 0.975 0.557
boot_ci(NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.650
## 2 0.975 0.703
boot_ci(NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.494
## 2 0.975 0.555
# PER.NEU.IMI
PER.NEU.IMI_optimal_cutpoint <- boot_ci(PER.NEU.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 44.9
## 2 0.975 72.1
PER.NEU.IMI_lower_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.IMI_upper_ci <- subset(PER.NEU.IMI_optimal_cutpoint, PER.NEU.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0943
## 2 0.975 0.896
boot_ci(PER.NEU.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.161
## 2 0.975 0.945
boot_ci(PER.NEU.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.345
## 2 0.975 0.475
boot_ci(PER.NEU.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.647
## 2 0.975 0.743
boot_ci(PER.NEU.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.488
## 2 0.975 0.550
# LYM.IMI
LYM.IMI_optimal_cutpoint <- boot_ci(LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.IMI_lower_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.IMI_lower_ci)
## [1] 12
LYM.IMI_upper_ci <- subset(LYM.IMI_optimal_cutpoint, LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.IMI_upper_ci)
## [1] 27
boot_ci(LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.179
## 2 0.975 0.509
boot_ci(LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.585
## 2 0.975 0.894
boot_ci(LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.378
## 2 0.975 0.522
boot_ci(LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.651
## 2 0.975 0.706
boot_ci(LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.498
## 2 0.975 0.560
# PER.LYM.IMI
PER.LYM.IMI_optimal_cutpoint <- boot_ci(PER.LYM.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 18.7
## 2 0.975 39.0
PER.LYM.IMI_lower_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.IMI_upper_ci <- subset(PER.LYM.IMI_optimal_cutpoint, PER.LYM.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0334
## 2 0.975 0.649
boot_ci(PER.LYM.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.394
## 2 0.975 0.979
boot_ci(PER.LYM.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.342
## 2 0.975 0.467
boot_ci(PER.LYM.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.641
## 2 0.975 0.704
boot_ci(PER.LYM.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.470
## 2 0.975 0.530
# MAC.IMI
MAC.IMI_optimal_cutpoint <- boot_ci(MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.IMI_lower_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.IMI_lower_ci)
## [1] 10
MAC.IMI_upper_ci <- subset(MAC.IMI_optimal_cutpoint, MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.IMI_upper_ci)
## [1] 38
boot_ci(MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.126
## 2 0.975 0.534
boot_ci(MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.535
## 2 0.975 0.926
boot_ci(MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.366
## 2 0.975 0.529
boot_ci(MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.646
## 2 0.975 0.703
boot_ci(MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.488
## 2 0.975 0.548
# PER.MAC.IMI
PER.MAC.IMI_optimal_cutpoint <- boot_ci(PER.MAC.IMI, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.IMI_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 7.79
## 2 0.975 34.6
PER.MAC.IMI_lower_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.IMI_upper_ci <- subset(PER.MAC.IMI_optimal_cutpoint, PER.MAC.IMI_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.IMI, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.183
## 2 0.975 0.957
boot_ci(PER.MAC.IMI, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.0938
## 2 0.975 0.876
boot_ci(PER.MAC.IMI, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.251
## 2 0.975 0.344
boot_ci(PER.MAC.IMI, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.744
## 2 0.975 0.874
boot_ci(PER.MAC.IMI, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.493
## 2 0.975 0.557
# Prevalence
# True prevalence
table(Pc.by.quarter.C5$IMI)
##
## 0 1
## 1020 543
prop.table(table(Pc.by.quarter.C5$IMI))
##
## 0 1
## 0.6525912 0.3474088
#Apparent prevalence
# ---- SCC ----
# optimal cut-off
optimal_scc_C5_IMI_quarter <- SCC.IMI$optimal_cutpoint
table(Pc.by.quarter.C5$test_result_n > exp(optimal_scc_C5_IMI_quarter))
##
## FALSE TRUE
## 1394 248
prop.table(table(Pc.by.quarter.C5$test_result_n > exp(optimal_scc_C5_IMI_quarter)))
##
## FALSE TRUE
## 0.8489647 0.1510353
# confidence intervals
table(Pc.by.quarter.C5$test_result_n > exp(SCC.IMI_lower_ci))
##
## FALSE TRUE
## 1128 514
prop.table(table(Pc.by.quarter.C5$test_result_n > exp(SCC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.6869671 0.3130329
table(Pc.by.quarter.C5$test_result_n > exp(SCC.IMI_upper_ci))
##
## FALSE TRUE
## 1524 118
prop.table(table(Pc.by.quarter.C5$test_result_n >exp(SCC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.92813642 0.07186358
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C5_IMI_quarter <- NEU.IMI$optimal_cutpoint
table(Pc.by.quarter.C5$TOTAL01_N > exp(optimal_neu_C5_IMI_quarter))
##
## FALSE TRUE
## 1310 337
prop.table(table(Pc.by.quarter.C5$TOTAL01_N > exp(optimal_neu_C5_IMI_quarter)))
##
## FALSE TRUE
## 0.7953855 0.2046145
# confidence intervals
table(Pc.by.quarter.C5$TOTAL01_N > exp(NEU.IMI_lower_ci))
##
## FALSE TRUE
## 1071 576
prop.table(table(Pc.by.quarter.C5$TOTAL01_N > exp(NEU.IMI_lower_ci)))
##
## FALSE TRUE
## 0.6502732 0.3497268
table(Pc.by.quarter.C5$TOTAL01_N > exp(NEU.IMI_upper_ci))
##
## FALSE TRUE
## 1552 95
prop.table(table(Pc.by.quarter.C5$TOTAL01_N >exp(NEU.IMI_upper_ci)))
##
## FALSE TRUE
## 0.94231937 0.05768063
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C5_IMI_quarter <- PER.NEU.IMI$optimal_cutpoint
table(Pc.by.quarter.C5$PERCENT01_N > optimal_per_neu_C5_IMI_quarter)
##
## FALSE TRUE
## 1091 556
prop.table(table(Pc.by.quarter.C5$PERCENT01_N > optimal_per_neu_C5_IMI_quarter))
##
## FALSE TRUE
## 0.6624165 0.3375835
# confidence intervals
table(Pc.by.quarter.C5$PERCENT01_N > PER.NEU.IMI_lower_ci)
##
## FALSE TRUE
## 228 1419
prop.table(table(Pc.by.quarter.C5$PERCENT01_N > PER.NEU.IMI_lower_ci))
##
## FALSE TRUE
## 0.1384335 0.8615665
table(Pc.by.quarter.C5$PERCENT01_N > PER.NEU.IMI_upper_ci)
##
## FALSE TRUE
## 1543 104
prop.table(table(Pc.by.quarter.C5$PERCENT01_N >PER.NEU.IMI_upper_ci))
##
## FALSE TRUE
## 0.93685489 0.06314511
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C5_IMI_quarter <-LYM.IMI$optimal_cutpoint
table(Pc.by.quarter.C5$TOTAL02_N > exp(optimal_lym_C5_IMI_quarter))
##
## FALSE TRUE
## 1378 269
prop.table(table(Pc.by.quarter.C5$TOTAL02_N > exp(optimal_lym_C5_IMI_quarter)))
##
## FALSE TRUE
## 0.8366727 0.1633273
# confidence intervals
table(Pc.by.quarter.C5$TOTAL02_N > exp(LYM.IMI_lower_ci))
##
## FALSE TRUE
## 995 652
prop.table(table(Pc.by.quarter.C5$TOTAL02_N > exp(LYM.IMI_lower_ci)))
##
## FALSE TRUE
## 0.6041287 0.3958713
table(Pc.by.quarter.C5$TOTAL02_N > exp(LYM.IMI_upper_ci))
##
## FALSE TRUE
## 1422 225
prop.table(table(Pc.by.quarter.C5$TOTAL02_N >exp(LYM.IMI_upper_ci)))
##
## FALSE TRUE
## 0.863388 0.136612
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C5_IMI_quarter <-PER.LYM.IMI$optimal_cutpoint
table(Pc.by.quarter.C5$PERCENT02_N > optimal_per_lym_C5_IMI_quarter)
##
## FALSE TRUE
## 894 753
prop.table(table(Pc.by.quarter.C5$PERCENT02_N > optimal_per_lym_C5_IMI_quarter))
##
## FALSE TRUE
## 0.5428051 0.4571949
# confidence intervals
table(Pc.by.quarter.C5$PERCENT02_N > PER.LYM.IMI_lower_ci)
##
## FALSE TRUE
## 624 1023
prop.table(table(Pc.by.quarter.C5$PERCENT02_N > PER.LYM.IMI_lower_ci))
##
## FALSE TRUE
## 0.3788707 0.6211293
table(Pc.by.quarter.C5$PERCENT02_N > PER.LYM.IMI_upper_ci)
##
## FALSE TRUE
## 1601 46
prop.table(table(Pc.by.quarter.C5$PERCENT02_N >PER.LYM.IMI_upper_ci))
##
## FALSE TRUE
## 0.97207043 0.02792957
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C5_IMI_quarter <- MAC.IMI$optimal_cutpoint
table(Pc.by.quarter.C5$TOTAL03_N > exp(optimal_mac_C5_IMI_quarter))
##
## FALSE TRUE
## 1464 183
prop.table(table(Pc.by.quarter.C5$TOTAL03_N > exp(optimal_mac_C5_IMI_quarter)))
##
## FALSE TRUE
## 0.8888889 0.1111111
# confidence intervals
table(Pc.by.quarter.C5$TOTAL03_N > exp(MAC.IMI_lower_ci))
##
## FALSE TRUE
## 927 720
prop.table(table(Pc.by.quarter.C5$TOTAL03_N > exp(MAC.IMI_lower_ci)))
##
## FALSE TRUE
## 0.5628415 0.4371585
table(Pc.by.quarter.C5$TOTAL03_N > exp(MAC.IMI_upper_ci))
##
## FALSE TRUE
## 1488 159
prop.table(table(Pc.by.quarter.C5$TOTAL03_N >exp(MAC.IMI_upper_ci)))
##
## FALSE TRUE
## 0.90346084 0.09653916
# Percent MAC
# optimal cut-off
optimal_per_mac_C5_IMI_quarter <- PER.MAC.IMI$optimal_cutpoint
table(Pc.by.quarter.C5$PERCENT03_N > optimal_per_mac_C5_IMI_quarter)
##
## FALSE TRUE
## 1154 493
prop.table(table(Pc.by.quarter.C5$PERCENT03_N > optimal_per_mac_C5_IMI_quarter))
##
## FALSE TRUE
## 0.7006679 0.2993321
# confidence intervals
table(Pc.by.quarter.C5$PERCENT03_N > PER.MAC.IMI_lower_ci)
##
## FALSE TRUE
## 132 1515
prop.table(table(Pc.by.quarter.C5$PERCENT03_N > PER.MAC.IMI_lower_ci))
##
## FALSE TRUE
## 0.08014572 0.91985428
table(Pc.by.quarter.C5$PERCENT03_N > PER.MAC.IMI_upper_ci)
##
## FALSE TRUE
## 1419 228
prop.table(table(Pc.by.quarter.C5$PERCENT03_N >PER.MAC.IMI_upper_ci))
##
## FALSE TRUE
## 0.8615665 0.1384335
# Set a seed for reproducibility
set.seed(123)
# Qscout subclinical mastitis reference
# n NEU SCM quarter
NEU.delaval.SCM <- cutpointr(Pc.by.quarter.C5, log.Neu, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(NEU.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Neu
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.936 1639 144 1495
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 4.4308 1.8015 0.9506 0.8403 0.9612 0.676 0.9842 121
## fn fp tn
## 23 58 1437
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 1.098612 2.185446 2.772589 3.258097 3.420589 3.806662 5.293305
## 0 1.098612 2.079442 2.772589 3.178054 3.199462 3.650574 4.356709
## 1 1.386294 3.306556 4.764247 5.379632 5.716317 6.676715 8.923461
## Max. SD NAs
## 10.17477 1.1011778 0
## 8.40268 0.7124932 0
## 10.17477 1.6636133 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 4.25 4.25 4.43 4.43 4.43 4.44 4.48 4.74 0.06 0
## AUC_b 0.88 0.91 0.93 0.94 0.94 0.95 0.96 0.97 0.01 0
## AUC_oob 0.88 0.91 0.92 0.94 0.94 0.95 0.96 0.99 0.02 0
## sum_sens_spec_b 1.69 1.75 1.78 1.80 1.80 1.82 1.85 1.91 0.03 0
## sum_sens_spec_oob 1.60 1.71 1.76 1.79 1.79 1.82 1.86 1.93 0.04 0
## acc_b 0.91 0.93 0.95 0.95 0.95 0.96 0.96 0.98 0.01 0
## acc_oob 0.90 0.92 0.94 0.95 0.95 0.95 0.96 0.98 0.01 0
## sensitivity_b 0.73 0.79 0.82 0.84 0.84 0.86 0.89 0.94 0.03 0
## sensitivity_oob 0.64 0.75 0.80 0.83 0.83 0.86 0.90 0.98 0.05 0
## specificity_b 0.92 0.94 0.96 0.96 0.96 0.97 0.97 0.99 0.01 0
## specificity_oob 0.91 0.93 0.96 0.96 0.96 0.97 0.97 0.99 0.01 0
## cohens_kappa_b 0.58 0.65 0.70 0.72 0.72 0.75 0.78 0.85 0.04 0
## cohens_kappa_oob 0.50 0.62 0.68 0.71 0.71 0.74 0.78 0.87 0.05 0
## ppv_b 0.49 0.57 0.65 0.68 0.67 0.70 0.75 0.90 0.05 0
## ppv_oob 0.41 0.55 0.63 0.67 0.67 0.71 0.77 0.92 0.06 0
## npv_b 0.97 0.98 0.98 0.98 0.98 0.99 0.99 0.99 0.00 0
## npv_oob 0.96 0.98 0.98 0.98 0.98 0.99 0.99 1.00 0.00 0
# ROC plot
plot(NEU.delaval.SCM)
# Youden index plot
plot_metric(NEU.delaval.SCM)
# %NEU SCM quarter
PER.NEU.delaval.SCM <- cutpointr(Pc.by.quarter.C5, PERCENT01_N, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.NEU.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT01_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5201 1639 144 1495
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 60.79 1.1287 0.6632 0.4444 0.6843 0.1194 0.9275 64
## fn fp tn
## 80 472 1023
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## Overall 13.79 38.090 49.740 56.320 56.24826 63.27 73.6800 89.55 10.70931
## 0 13.79 38.668 50.000 56.250 56.25045 62.91 73.6090 89.55 10.45925
## 1 21.89 32.215 46.665 58.425 56.22542 66.01 74.6815 78.90 13.06880
## NAs
## 0
## 0
## 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 57.44 59.65 60.79 61.18 62.17 63.67 65.50 72.37 2.25
## AUC_b 0.42 0.47 0.50 0.52 0.52 0.54 0.57 0.63 0.03
## AUC_oob 0.37 0.46 0.49 0.52 0.52 0.54 0.58 0.65 0.04
## sum_sens_spec_b 1.00 1.08 1.12 1.15 1.15 1.17 1.21 1.28 0.04
## sum_sens_spec_oob 0.84 1.00 1.05 1.09 1.09 1.12 1.18 1.28 0.05
## acc_b 0.54 0.62 0.65 0.69 0.70 0.74 0.78 0.88 0.05
## acc_oob 0.54 0.61 0.65 0.68 0.69 0.73 0.78 0.87 0.06
## sensitivity_b 0.10 0.28 0.37 0.43 0.42 0.48 0.54 0.64 0.08
## sensitivity_oob 0.02 0.21 0.31 0.38 0.37 0.43 0.50 0.62 0.09
## specificity_b 0.53 0.63 0.67 0.71 0.72 0.77 0.82 0.95 0.07
## specificity_oob 0.55 0.62 0.67 0.71 0.72 0.77 0.82 0.96 0.07
## cohens_kappa_b 0.00 0.04 0.06 0.07 0.07 0.09 0.11 0.16 0.02
## cohens_kappa_oob -0.08 0.00 0.03 0.04 0.04 0.06 0.09 0.14 0.03
## ppv_b 0.09 0.11 0.12 0.13 0.13 0.14 0.16 0.25 0.02
## ppv_oob 0.02 0.08 0.10 0.11 0.11 0.13 0.15 0.19 0.02
## npv_b 0.90 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.01
## npv_oob 0.89 0.91 0.92 0.92 0.92 0.93 0.94 0.96 0.01
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.NEU.delaval.SCM)
# Youden index plot
plot_metric(PER.NEU.delaval.SCM)
# LYM SCM quarter
LYM.delaval.SCM <- cutpointr(Pc.by.quarter.C5, log.Lym, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(LYM.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Lym
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9314 1639 144 1495
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 3.2189 1.782 0.9042 0.875 0.907 0.4755 0.9869
## tp fn fp tn
## 126 18 139 1356
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 1.098612 1.791759 2.302585 2.421411 2.890372 4.317488
## 0 0.000000 1.098612 1.609438 2.197225 2.219420 2.708050 3.433987
## 1 1.609438 2.213029 3.637586 4.330733 4.518462 5.395708 7.259279
## Max. SD NAs
## 8.165932 1.0720204 0
## 7.006695 0.7766316 0
## 8.165932 1.4168435 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.09 3.22 3.22 3.22 3.28 3.33 3.40 3.74 0.09 0
## AUC_b 0.88 0.91 0.92 0.93 0.93 0.94 0.95 0.98 0.01 0
## AUC_oob 0.87 0.90 0.92 0.93 0.93 0.95 0.96 0.99 0.02 0
## sum_sens_spec_b 1.67 1.74 1.77 1.79 1.79 1.81 1.83 1.88 0.03 0
## sum_sens_spec_oob 1.57 1.69 1.74 1.77 1.76 1.80 1.83 1.90 0.04 0
## acc_b 0.86 0.90 0.90 0.91 0.92 0.93 0.94 0.97 0.02 0
## acc_oob 0.84 0.89 0.90 0.91 0.91 0.92 0.94 0.96 0.02 0
## sensitivity_b 0.74 0.81 0.84 0.87 0.87 0.89 0.92 0.97 0.03 0
## sensitivity_oob 0.61 0.75 0.81 0.85 0.85 0.88 0.93 0.98 0.05 0
## specificity_b 0.86 0.90 0.91 0.92 0.92 0.94 0.95 0.98 0.02 0
## specificity_oob 0.85 0.89 0.90 0.92 0.92 0.93 0.95 0.98 0.02 0
## cohens_kappa_b 0.46 0.53 0.56 0.59 0.60 0.64 0.70 0.80 0.05 0
## cohens_kappa_oob 0.37 0.50 0.55 0.58 0.58 0.62 0.67 0.74 0.05 0
## ppv_b 0.38 0.44 0.47 0.50 0.52 0.56 0.63 0.80 0.06 0
## ppv_oob 0.30 0.41 0.46 0.50 0.51 0.54 0.62 0.77 0.07 0
## npv_b 0.97 0.98 0.98 0.99 0.99 0.99 0.99 1.00 0.00 0
## npv_oob 0.96 0.97 0.98 0.98 0.98 0.99 0.99 1.00 0.01 0
# ROC plot
plot(LYM.delaval.SCM)
# Youden index plot
plot_metric(LYM.delaval.SCM)
# %LYM SCM quarter
PER.LYM.delaval.SCM <- cutpointr(Pc.by.quarter.C5, PERCENT02_N, delaval.SCM,
method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 0
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.LYM.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT02_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.6575 1639 1495 144
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv
## 21.54 1.2785 0.5308 0.5077 0.7708 0.9583 0.1311
## tp fn fp tn
## 759 736 33 111
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.00 9.800 16.1450 21.210 21.87254 27.075 36.567 61.54 8.148360 0
## 0 0.00 10.000 16.4750 21.670 22.25621 27.530 37.033 61.54 8.190777 0
## 1 1.52 9.013 13.4675 17.505 17.88938 21.440 29.937 35.38 6.488743 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 14.55 20.00 20.95 21.54 21.37 22.03 22.45 27.14 1.01
## AUC_b 0.58 0.62 0.64 0.66 0.66 0.67 0.69 0.72 0.02
## AUC_oob 0.55 0.61 0.64 0.66 0.66 0.68 0.71 0.75 0.03
## sum_sens_spec_b 1.17 1.23 1.26 1.29 1.29 1.31 1.34 1.42 0.04
## sum_sens_spec_oob 1.00 1.15 1.21 1.25 1.25 1.29 1.34 1.45 0.06
## acc_b 0.32 0.49 0.51 0.53 0.54 0.56 0.60 0.80 0.04
## acc_oob 0.31 0.48 0.51 0.53 0.53 0.55 0.60 0.77 0.04
## sensitivity_b 0.26 0.46 0.49 0.51 0.52 0.54 0.59 0.83 0.05
## sensitivity_oob 0.25 0.45 0.48 0.51 0.51 0.53 0.59 0.83 0.05
## specificity_b 0.40 0.68 0.74 0.78 0.77 0.81 0.84 0.93 0.06
## specificity_oob 0.24 0.59 0.70 0.75 0.74 0.79 0.84 0.95 0.09
## cohens_kappa_b 0.04 0.07 0.08 0.09 0.09 0.10 0.12 0.20 0.02
## cohens_kappa_oob 0.00 0.05 0.07 0.08 0.08 0.09 0.11 0.15 0.02
## ppv_b 0.93 0.95 0.95 0.96 0.96 0.96 0.97 0.98 0.01
## ppv_oob 0.90 0.93 0.95 0.95 0.95 0.96 0.97 0.99 0.01
## npv_b 0.09 0.11 0.13 0.13 0.13 0.14 0.15 0.23 0.01
## npv_oob 0.08 0.10 0.12 0.13 0.13 0.14 0.15 0.19 0.02
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.LYM.delaval.SCM)
# Youden index plot
plot_metric(PER.LYM.delaval.SCM)
# MAC SCM quarter
MAC.delaval.SCM <- cutpointr(Pc.by.quarter.C5, log.Mac, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(MAC.delaval.SCM)
## Method: maximize_metric
## Predictor: log.Mac
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.9497 1639 144 1495
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 3.0445 1.7784 0.878 0.9028 0.8756 0.4114 0.9894 130
## fn fp tn
## 14 186 1309
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95%
## Overall 0.000000 0.6931472 1.609438 2.197225 2.345712 2.772589 4.443821
## 0 0.000000 0.6931472 1.609438 2.079442 2.108938 2.639057 3.443512
## 1 1.791759 2.5649494 3.555348 4.599842 4.803890 5.860774 7.942045
## Max. SD NAs
## 9.127176 1.1999069 0
## 7.458186 0.8311637 0
## 9.127176 1.6135293 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## optimal_cutpoint 3.04 3.04 3.04 3.09 3.12 3.18 3.26 3.89 0.09 0
## AUC_b 0.90 0.93 0.94 0.95 0.95 0.96 0.97 0.98 0.01 0
## AUC_oob 0.91 0.93 0.94 0.95 0.95 0.96 0.97 0.99 0.01 0
## sum_sens_spec_b 1.67 1.74 1.77 1.78 1.78 1.80 1.83 1.89 0.03 0
## sum_sens_spec_oob 1.52 1.69 1.74 1.77 1.76 1.79 1.82 1.89 0.04 0
## acc_b 0.86 0.87 0.88 0.89 0.89 0.90 0.92 0.97 0.02 0
## acc_oob 0.84 0.86 0.88 0.89 0.89 0.90 0.91 0.95 0.02 0
## sensitivity_b 0.73 0.84 0.87 0.89 0.89 0.91 0.94 0.98 0.03 0
## sensitivity_oob 0.54 0.78 0.84 0.88 0.87 0.91 0.94 1.00 0.05 0
## specificity_b 0.85 0.87 0.88 0.89 0.89 0.91 0.92 0.99 0.02 0
## specificity_oob 0.84 0.86 0.88 0.89 0.89 0.91 0.92 0.99 0.02 0
## cohens_kappa_b 0.41 0.47 0.51 0.54 0.54 0.57 0.61 0.81 0.05 0
## cohens_kappa_oob 0.33 0.45 0.49 0.52 0.52 0.56 0.60 0.73 0.05 0
## ppv_b 0.33 0.38 0.41 0.44 0.45 0.48 0.52 0.83 0.05 0
## ppv_oob 0.26 0.36 0.40 0.43 0.44 0.47 0.52 0.81 0.05 0
## npv_b 0.98 0.98 0.99 0.99 0.99 0.99 0.99 1.00 0.00 0
## npv_oob 0.96 0.98 0.98 0.99 0.99 0.99 0.99 1.00 0.01 0
# ROC plot
plot(MAC.delaval.SCM)
# Youden index plot
plot_metric(MAC.delaval.SCM)
# %MAC SCM quarter
PER.MAC.delaval.SCM<- cutpointr(Pc.by.quarter.C5, PERCENT03_N, delaval.SCM, method = maximize_metric, metric = sum_sens_spec,na.rm=TRUE, boot_runs = 2000) %>% add_metric(list(ppv, npv))
## Assuming the positive class is 1
## Assuming the positive class has higher x values
## Running bootstrap...
# Summary
summary(PER.MAC.delaval.SCM)
## Method: maximize_metric
## Predictor: PERCENT03_N
## Outcome: delaval.SCM
## Direction: >=
## Nr. of bootstraps: 2000
##
## AUC n n_pos n_neg
## 0.5875 1639 144 1495
##
## optimal_cutpoint sum_sens_spec acc sensitivity specificity ppv npv tp
## 26.39 1.1878 0.6827 0.4861 0.7017 0.1357 0.9341 70
## fn fp tn
## 74 446 1049
##
## Predictor summary:
## Data Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD NAs
## Overall 0.00 6.450 13.0400 20.00 21.87892 28.800 43.5590 71.43 11.60963 0
## 0 0.00 6.441 13.0400 19.77 21.49295 28.310 41.9520 71.43 11.29463 0
## 1 4.99 7.109 13.7875 25.17 25.88604 35.085 50.7025 69.06 13.90600 0
##
## Bootstrap summary:
## Variable Min. 5% 1st Qu. Median Mean 3rd Qu. 95% Max. SD
## optimal_cutpoint 17.90 22.84 23.53 26.39 26.71 29.58 31.70 41.24 3.28
## AUC_b 0.47 0.54 0.57 0.59 0.59 0.61 0.63 0.67 0.03
## AUC_oob 0.45 0.53 0.56 0.59 0.59 0.61 0.65 0.71 0.04
## sum_sens_spec_b 1.06 1.14 1.18 1.20 1.20 1.23 1.27 1.33 0.04
## sum_sens_spec_oob 0.95 1.06 1.11 1.15 1.15 1.18 1.24 1.32 0.06
## acc_b 0.47 0.60 0.63 0.69 0.69 0.75 0.79 0.89 0.07
## acc_oob 0.45 0.59 0.62 0.67 0.68 0.74 0.79 0.87 0.07
## sensitivity_b 0.14 0.34 0.43 0.51 0.50 0.57 0.63 0.73 0.09
## sensitivity_oob 0.10 0.27 0.37 0.45 0.44 0.52 0.60 0.69 0.10
## specificity_b 0.44 0.60 0.63 0.70 0.71 0.78 0.83 0.95 0.08
## specificity_oob 0.43 0.59 0.63 0.70 0.70 0.78 0.83 0.95 0.08
## cohens_kappa_b 0.03 0.06 0.08 0.10 0.10 0.12 0.15 0.22 0.03
## cohens_kappa_oob -0.02 0.02 0.05 0.07 0.07 0.09 0.12 0.20 0.03
## ppv_b 0.09 0.12 0.13 0.14 0.14 0.16 0.19 0.27 0.02
## ppv_oob 0.06 0.09 0.11 0.13 0.13 0.14 0.17 0.28 0.02
## npv_b 0.91 0.92 0.93 0.94 0.94 0.94 0.95 0.96 0.01
## npv_oob 0.88 0.91 0.92 0.93 0.93 0.94 0.95 0.96 0.01
## NAs
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
## 0
# ROC plot
plot(PER.MAC.delaval.SCM)
# Youden index plot
plot_metric(PER.MAC.delaval.SCM)
# Summary of results when using SCM as reference
print(c("Optimal n NEU:", exp(NEU.delaval.SCM$optimal_cutpoint), NEU.delaval.SCM$sensitivity, NEU.delaval.SCM$specificity, NEU.delaval.SCM$ppv, NEU.delaval.SCM$npv, NEU.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n NEU:" "84" "0.840277777777778" "0.961204013377926"
##
## "0.675977653631285" "0.984246575342466" "0.936022853957637"
print(c("Optimal %NEU:", PER.NEU.delaval.SCM$optimal_cutpoint, PER.NEU.delaval.SCM$sensitivity, PER.NEU.delaval.SCM$specificity, PER.NEU.delaval.SCM$ppv, PER.NEU.delaval.SCM$npv, PER.NEU.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %NEU:" "60.79" "0.444444444444444" "0.68428093645485"
##
## "0.119402985074627" "0.927470534904805" "0.520080824972129"
print(c("Optimal n LYM:", exp(LYM.delaval.SCM$optimal_cutpoint), LYM.delaval.SCM$sensitivity, LYM.delaval.SCM$specificity, LYM.delaval.SCM$ppv, LYM.delaval.SCM$npv, LYM.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n LYM:" "25" "0.875" "0.907023411371237"
##
## "0.475471698113208" "0.986899563318777" "0.931400966183575"
print(c("Optimal %LYM:", PER.LYM.delaval.SCM$optimal_cutpoint, PER.LYM.delaval.SCM$sensitivity, PER.LYM.delaval.SCM$specificity, PER.LYM.delaval.SCM$ppv, PER.LYM.delaval.SCM$npv, PER.LYM.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %LYM:" "21.54" "0.507692307692308" "0.770833333333333"
##
## "0.958333333333333" "0.131050767414404" "0.657541341508733"
print(c("Optimal n MAC:", exp(MAC.delaval.SCM$optimal_cutpoint), MAC.delaval.SCM$sensitivity, MAC.delaval.SCM$specificity, MAC.delaval.SCM$ppv, MAC.delaval.SCM$npv, MAC.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal n MAC:" "21" "0.902777777777778" "0.875585284280936"
##
## "0.411392405063291" "0.989417989417989" "0.949716648086213"
print(c("Optimal %MAC:", PER.MAC.delaval.SCM$optimal_cutpoint, PER.MAC.delaval.SCM$sensitivity, PER.MAC.delaval.SCM$specificity, PER.MAC.delaval.SCM$ppv, PER.MAC.delaval.SCM$npv, PER.MAC.delaval.SCM$AUC))
## sensitivity specificity
## "Optimal %MAC:" "26.39" "0.486111111111111" "0.701672240802676"
##
## "0.135658914728682" "0.934105075690116" "0.587541806020067"
# CI using bootstrapping
# NEU.delaval.SCM
NEU.delaval.SCM_optimal_cutpoint <- boot_ci(NEU.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
NEU.delaval.SCM_lower_ci <- subset(NEU.delaval.SCM_optimal_cutpoint, NEU.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(NEU.delaval.SCM_lower_ci)
## [1] 70
NEU.delaval.SCM_upper_ci <- subset(NEU.delaval.SCM_optimal_cutpoint, NEU.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(NEU.delaval.SCM_upper_ci)
## [1] 99
boot_ci(NEU.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.775
## 2 0.975 0.899
boot_ci(NEU.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.933
## 2 0.975 0.976
boot_ci(NEU.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.547
## 2 0.975 0.774
boot_ci(NEU.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.977
## 2 0.975 0.990
boot_ci(NEU.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.908
## 2 0.975 0.960
# PER.NEU.delaval.SCM
PER.NEU.delaval.SCM_optimal_cutpoint <- boot_ci(PER.NEU.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.NEU.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 59.2
## 2 0.975 67.3
PER.NEU.delaval.SCM_lower_ci <- subset(PER.NEU.delaval.SCM_optimal_cutpoint, PER.NEU.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.NEU.delaval.SCM_upper_ci <- subset(PER.NEU.delaval.SCM_optimal_cutpoint, PER.NEU.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.NEU.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.253
## 2 0.975 0.557
boot_ci(PER.NEU.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.619
## 2 0.975 0.863
boot_ci(PER.NEU.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.101
## 2 0.975 0.167
boot_ci(PER.NEU.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.914
## 2 0.975 0.944
boot_ci(PER.NEU.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.464
## 2 0.975 0.578
# LYM.delaval.SCM
LYM.delaval.SCM_optimal_cutpoint <- boot_ci(LYM.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
LYM.delaval.SCM_lower_ci <- subset(LYM.delaval.SCM_optimal_cutpoint, LYM.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(LYM.delaval.SCM_lower_ci)
## [1] 25
LYM.delaval.SCM_upper_ci <- subset(LYM.delaval.SCM_optimal_cutpoint, LYM.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(LYM.delaval.SCM_upper_ci)
## [1] 35
boot_ci(LYM.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.8
## 2 0.975 0.923
boot_ci(LYM.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.895
## 2 0.975 0.963
boot_ci(LYM.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.424
## 2 0.975 0.674
boot_ci(LYM.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.979
## 2 0.975 0.992
boot_ci(LYM.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.901
## 2 0.975 0.958
# PER.LYM.delaval.SCM
PER.LYM.delaval.SCM_optimal_cutpoint <- boot_ci(PER.LYM.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.LYM.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 18.2
## 2 0.975 22.4
PER.LYM.delaval.SCM_lower_ci <- subset(PER.LYM.delaval.SCM_optimal_cutpoint, PER.LYM.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.LYM.delaval.SCM_upper_ci <- subset(PER.LYM.delaval.SCM_optimal_cutpoint, PER.LYM.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.LYM.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.452
## 2 0.975 0.681
boot_ci(PER.LYM.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.610
## 2 0.975 0.857
boot_ci(PER.LYM.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.943
## 2 0.975 0.973
boot_ci(PER.LYM.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.110
## 2 0.975 0.160
boot_ci(PER.LYM.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.611
## 2 0.975 0.698
# MAC.delaval.SCM
MAC.delaval.SCM_optimal_cutpoint <- boot_ci(MAC.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
MAC.delaval.SCM_lower_ci <- subset(MAC.delaval.SCM_optimal_cutpoint, MAC.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
exp(MAC.delaval.SCM_lower_ci)
## [1] 21
MAC.delaval.SCM_upper_ci <- subset(MAC.delaval.SCM_optimal_cutpoint, MAC.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
exp(MAC.delaval.SCM_upper_ci)
## [1] 26
boot_ci(MAC.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.832
## 2 0.975 0.942
boot_ci(MAC.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.863
## 2 0.975 0.927
boot_ci(MAC.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.369
## 2 0.975 0.545
boot_ci(MAC.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.982
## 2 0.975 0.994
boot_ci(MAC.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.930
## 2 0.975 0.968
# PER.MAC.delaval.SCM
PER.MAC.delaval.SCM_optimal_cutpoint <- boot_ci(PER.MAC.delaval.SCM, optimal_cutpoint, in_bag = TRUE, alpha = 0.05)
PER.MAC.delaval.SCM_optimal_cutpoint
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 22.8
## 2 0.975 32.1
PER.MAC.delaval.SCM_lower_ci <- subset(PER.MAC.delaval.SCM_optimal_cutpoint, PER.MAC.delaval.SCM_optimal_cutpoint$quantile == 0.025)$values
PER.MAC.delaval.SCM_upper_ci <- subset(PER.MAC.delaval.SCM_optimal_cutpoint, PER.MAC.delaval.SCM_optimal_cutpoint$quantile == 0.975)$values
boot_ci(PER.MAC.delaval.SCM, sensitivity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.312
## 2 0.975 0.646
boot_ci(PER.MAC.delaval.SCM, specificity, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.592
## 2 0.975 0.844
boot_ci(PER.MAC.delaval.SCM, ppv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.111
## 2 0.975 0.195
boot_ci(PER.MAC.delaval.SCM, npv, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.921
## 2 0.975 0.951
boot_ci(PER.MAC.delaval.SCM, AUC, in_bag = TRUE, alpha = 0.05)
## # A tibble: 2 × 2
## quantile values
## <dbl> <dbl>
## 1 0.025 0.535
## 2 0.975 0.642
# Prevalence
# True prevalence
table(Pc.by.quarter.C5$delaval.SCM)
##
## 0 1
## 1497 145
prop.table(table(Pc.by.quarter.C5$delaval.SCM))
##
## 0 1
## 0.91169306 0.08830694
#Apparent prevalence
# ---- Neutrophils ----
# optimal cut-off
optimal_neu_C5_delaval.SCM_quarter <- NEU.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C5$TOTAL01_N > exp(optimal_neu_C5_delaval.SCM_quarter))
##
## FALSE TRUE
## 1464 183
prop.table(table(Pc.by.quarter.C5$TOTAL01_N > exp(optimal_neu_C5_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.8888889 0.1111111
# confidence intervals
table(Pc.by.quarter.C5$TOTAL01_N > exp(NEU.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1424 223
prop.table(table(Pc.by.quarter.C5$TOTAL01_N > exp(NEU.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.8646023 0.1353977
table(Pc.by.quarter.C5$TOTAL01_N > exp(NEU.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1492 155
prop.table(table(Pc.by.quarter.C5$TOTAL01_N >exp(NEU.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.9058895 0.0941105
# ---- Percent neu ----
# Optimal cut-off
optimal_per_neu_C5_delaval.SCM_quarter <- PER.NEU.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C5$PERCENT01_N > optimal_per_neu_C5_delaval.SCM_quarter)
##
## FALSE TRUE
## 1111 536
prop.table(table(Pc.by.quarter.C5$PERCENT01_N > optimal_per_neu_C5_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.6745598 0.3254402
# confidence intervals
table(Pc.by.quarter.C5$PERCENT01_N > PER.NEU.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 1007 640
prop.table(table(Pc.by.quarter.C5$PERCENT01_N > PER.NEU.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.6114147 0.3885853
table(Pc.by.quarter.C5$PERCENT01_N > PER.NEU.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 1407 240
prop.table(table(Pc.by.quarter.C5$PERCENT01_N >PER.NEU.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.8542805 0.1457195
# ---- Lymphocytes ----
# optimal cut-off
optimal_lym_C5_delaval.SCM_quarter <-LYM.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C5$TOTAL02_N > exp(optimal_lym_C5_delaval.SCM_quarter))
##
## FALSE TRUE
## 1378 269
prop.table(table(Pc.by.quarter.C5$TOTAL02_N > exp(optimal_lym_C5_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.8366727 0.1633273
# confidence intervals
table(Pc.by.quarter.C5$TOTAL02_N > exp(LYM.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1378 269
prop.table(table(Pc.by.quarter.C5$TOTAL02_N > exp(LYM.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.8366727 0.1633273
table(Pc.by.quarter.C5$TOTAL02_N > exp(LYM.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1476 171
prop.table(table(Pc.by.quarter.C5$TOTAL02_N >exp(LYM.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.8961749 0.1038251
# ---- Percent lym ----
# optimal cut-off
optimal_per_lym_C5_delaval.SCM_quarter <-PER.LYM.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C5$PERCENT02_N > optimal_per_lym_C5_delaval.SCM_quarter)
##
## FALSE TRUE
## 849 798
prop.table(table(Pc.by.quarter.C5$PERCENT02_N > optimal_per_lym_C5_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.5154827 0.4845173
# confidence intervals
table(Pc.by.quarter.C5$PERCENT02_N > PER.LYM.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 590 1057
prop.table(table(Pc.by.quarter.C5$PERCENT02_N > PER.LYM.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.3582271 0.6417729
table(Pc.by.quarter.C5$PERCENT02_N > PER.LYM.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 928 719
prop.table(table(Pc.by.quarter.C5$PERCENT02_N >PER.LYM.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.5634487 0.4365513
# ---- Macrophages ----
# optimal cut-off
optimal_mac_C5_delaval.SCM_quarter <- MAC.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C5$TOTAL03_N > exp(optimal_mac_C5_delaval.SCM_quarter))
##
## FALSE TRUE
## 1346 301
prop.table(table(Pc.by.quarter.C5$TOTAL03_N > exp(optimal_mac_C5_delaval.SCM_quarter)))
##
## FALSE TRUE
## 0.8172435 0.1827565
# confidence intervals
table(Pc.by.quarter.C5$TOTAL03_N > exp(MAC.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 1346 301
prop.table(table(Pc.by.quarter.C5$TOTAL03_N > exp(MAC.delaval.SCM_lower_ci)))
##
## FALSE TRUE
## 0.8172435 0.1827565
table(Pc.by.quarter.C5$TOTAL03_N > exp(MAC.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 1417 230
prop.table(table(Pc.by.quarter.C5$TOTAL03_N >exp(MAC.delaval.SCM_upper_ci)))
##
## FALSE TRUE
## 0.8603522 0.1396478
# Percent MAC
# optimal cut-off
optimal_per_mac_C5_delaval.SCM_quarter <- PER.MAC.delaval.SCM$optimal_cutpoint
table(Pc.by.quarter.C5$PERCENT03_N > optimal_per_mac_C5_delaval.SCM_quarter)
##
## FALSE TRUE
## 1132 515
prop.table(table(Pc.by.quarter.C5$PERCENT03_N > optimal_per_mac_C5_delaval.SCM_quarter))
##
## FALSE TRUE
## 0.6873103 0.3126897
# confidence intervals
table(Pc.by.quarter.C5$PERCENT03_N > PER.MAC.delaval.SCM_lower_ci)
##
## FALSE TRUE
## 974 673
prop.table(table(Pc.by.quarter.C5$PERCENT03_N > PER.MAC.delaval.SCM_lower_ci))
##
## FALSE TRUE
## 0.5913783 0.4086217
table(Pc.by.quarter.C5$PERCENT03_N > PER.MAC.delaval.SCM_upper_ci)
##
## FALSE TRUE
## 1358 289
prop.table(table(Pc.by.quarter.C5$PERCENT03_N > PER.MAC.delaval.SCM_upper_ci))
##
## FALSE TRUE
## 0.8245294 0.1754706
# ---- Plots ----
# Make sure outcomes are recognized as a factor
Doff.by.quarter.2$IMI <- as.factor(Doff.by.quarter.2$IMI)
Doff.by.quarter.2$delaval.SCM <- as.factor(Doff.by.quarter.2$delaval.SCM)
Pc.by.quarter.C3$IMI <- as.factor(Pc.by.quarter.C3$IMI)
Pc.by.quarter.C3$delaval.SCM <- as.factor(Pc.by.quarter.C3$delaval.SCM)
Pc.by.quarter.C5$IMI <- as.factor(Pc.by.quarter.C5$IMI)
Pc.by.quarter.C5$delaval.SCM <- as.factor(Pc.by.quarter.C5$delaval.SCM)
Doff.by.cow.3$IMI.cow <- as.factor(Doff.by.cow.3$IMI.cow)
Doff.by.cow.3$delaval.SCM.CO.COW <- as.factor(Doff.by.cow.3$delaval.SCM.CO.COW)
Pc.by.cow.C3$IMI.cow <- as.factor(Pc.by.cow.C3$IMI.cow)
Pc.by.cow.C3$delaval.SCM.CO.COW <- as.factor(Pc.by.cow.C3$delaval.SCM.CO.COW)
Pc.by.cow.C5$IMI.cow <- as.factor(Pc.by.cow.C5$IMI.cow)
Pc.by.cow.C5$delaval.SCM.CO.COW <- as.factor(Pc.by.cow.C5$delaval.SCM.CO.COW)
# ---- Detection of IMI quarter level ----
# Neu
theme_set(theme_bw())
# Dry-off
IMI.1_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(log.Neu) & !is.na(IMI)) %>%
ggplot(aes(x=log.Neu, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="") +
geom_vline(xintercept = optimal_neu_doff_IMI_quarter, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Lym
IMI.2_quarter_doff <-Doff.by.quarter.2 %>%
filter(!is.na(log.Lym) & !is.na(IMI)) %>%
ggplot(aes(x=log.Lym, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="") +
geom_vline(xintercept = optimal_lym_doff_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
IMI.3_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(log.Mac) & !is.na(IMI)) %>%
ggplot(aes(x=log.Mac, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="") +
geom_vline(xintercept = optimal_mac_doff_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
IMI.4_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(PERCENT01_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT01_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="") +
geom_vline(xintercept = optimal_per_neu_doff_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
IMI.5_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(PERCENT02_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT02_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="") +
geom_vline(xintercept = optimal_per_lym_doff_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
IMI.6_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(PERCENT03_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT03_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="") +
geom_vline(xintercept = optimal_per_mac_doff_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
IMI_quarter_doff <- ggarrange(IMI.1_quarter_doff + rremove("ylab"), IMI.2_quarter_doff + rremove("ylab"), IMI.3_quarter_doff + rremove("ylab"),
IMI.4_quarter_doff + rremove("ylab"), IMI.5_quarter_doff + rremove("ylab"), IMI.6_quarter_doff + rremove("ylab"),
ncol = 3, nrow = 2, common.legend = TRUE,align = "h",labels = c("A1", "B1", "C1","D1","E1","F1","G1"))
## Warning: Removed 18 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 18 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
IMI_quarter_doff_annotated <- annotate_figure(IMI_quarter_doff,
top = text_grob("Dry-off", color = "black",face="bold",size=20,
hjust = 0, x = 0,y=-0.75))
IMI_quarter_doff_annotated
ggsave(plot = last_plot(),"./figures/DSCC.IMI_quarter_doff.png",width = 20, height = 10, units = "cm")
# ---- C3 -----
# Neu
IMI.1_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(log.Neu) & !is.na(IMI)) %>%
ggplot(aes(x=log.Neu, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C3_IMI_quarter, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
IMI.2_quarter_C3 <-Pc.by.quarter.C3 %>%
filter(!is.na(log.Lym) & !is.na(IMI)) %>%
ggplot(aes(x=log.Lym, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C3_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
IMI.3_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(log.Mac) & !is.na(IMI)) %>%
ggplot(aes(x=log.Mac, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C3_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
IMI.4_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(PERCENT01_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT01_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C3_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
IMI.5_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(PERCENT02_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT02_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C3_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
IMI.6_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(PERCENT03_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT03_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C3_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
IMI_quarter_C3 <- ggarrange(IMI.1_quarter_C3 + rremove("ylab"), IMI.2_quarter_C3 + rremove("ylab"), IMI.3_quarter_C3 + rremove("ylab"),
IMI.4_quarter_C3 + rremove("ylab"), IMI.5_quarter_C3 + rremove("ylab"), IMI.6_quarter_C3 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A2", "B2", "C2","D2","E2","F2","G2"))
## Warning: Removed 11 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 3 rows containing non-finite outside the scale range
## (`stat_density()`).
IMI_quarter_C3_annotated <- annotate_figure(IMI_quarter_C3,
top = text_grob("Postpartum: 3 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
IMI_quarter_C3_annotated
ggsave(plot = last_plot(),"./figures/DSCC.IMI_quarter_C3.png",width = 20, height = 10, units = "cm")
# ---- c5 ----
# Neu
IMI.1_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(log.Neu) & !is.na(IMI)) %>%
ggplot(aes(x=log.Neu, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C5_IMI_quarter, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
IMI.2_quarter_C5 <-Pc.by.quarter.C5 %>%
filter(!is.na(log.Lym) & !is.na(IMI)) %>%
ggplot(aes(x=log.Lym, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C5_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
IMI.3_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(log.Mac) & !is.na(IMI)) %>%
ggplot(aes(x=log.Mac, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C5_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
IMI.4_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(PERCENT01_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT01_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C5_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
IMI.5_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(PERCENT02_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT02_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C5_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
IMI.6_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(PERCENT03_N) & !is.na(IMI)) %>%
ggplot(aes(x=PERCENT03_N, group=IMI, fill=IMI)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C5_IMI_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
IMI_quarter_C5 <- ggarrange(IMI.1_quarter_C5 + rremove("ylab"), IMI.2_quarter_C5 + rremove("ylab"), IMI.3_quarter_C5 + rremove("ylab"),
IMI.4_quarter_C5 + rremove("ylab"), IMI.5_quarter_C5 + rremove("ylab"), IMI.6_quarter_C5 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A3", "B3", "C3","D3","E3","F3","G3"))
## Warning: Removed 18 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_density()`).
IMI_quarter_C5_annotated <- annotate_figure(IMI_quarter_C5,
top = text_grob("Postpartum: 5 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
IMI_quarter_C5_annotated
ggsave(plot = last_plot(),"./figures/DSCC.IMI_quarter_C5.png",width = 20, height = 10, units = "cm")
DSCC.IMI_all <- ggarrange(IMI_quarter_doff_annotated + rremove("ylab"), IMI_quarter_C3_annotated + rremove("ylab"), IMI_quarter_C5_annotated + rremove("ylab"),
ncol = 1, nrow = 3, common.legend = TRUE,align = "h",widths = 4)
DSCC.IMI_all
ggsave(plot = last_plot(),"./figures/DSCC.IMI_quarter_all.png",width = 20, height = 30, units = "cm")
# ---- Subclinical mastitis quarter level ----
# Neu
SCM.1_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(log.Neu) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Neu, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fill="High SCC") +
geom_vline(xintercept = optimal_neu_doff_delaval.SCM_quarter, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
SCM.2_quarter_doff <-Doff.by.quarter.2 %>%
filter(!is.na(log.Lym) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Lym, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fill="High SCC") +
geom_vline(xintercept = optimal_lym_doff_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
SCM.3_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(log.Mac) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Mac, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fill="High SCC") +
geom_vline(xintercept = optimal_mac_doff_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
SCM.4_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(PERCENT01_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT01_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fill="High SCC") +
geom_vline(xintercept = optimal_per_neu_doff_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
SCM.5_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(PERCENT02_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT02_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fill="High SCC") +
geom_vline(xintercept = optimal_per_lym_doff_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
SCM.6_quarter_doff <- Doff.by.quarter.2 %>%
filter(!is.na(PERCENT03_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT03_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fill="High SCC") +
geom_vline(xintercept = optimal_per_mac_doff_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
delaval.SCM_quarter_doff <- ggarrange(SCM.1_quarter_doff + rremove("ylab"), SCM.2_quarter_doff + rremove("ylab"), SCM.3_quarter_doff + rremove("ylab"),
SCM.4_quarter_doff + rremove("ylab"), SCM.5_quarter_doff + rremove("ylab"), SCM.6_quarter_doff + rremove("ylab"),
ncol = 3, nrow = 2, common.legend = TRUE,align = "h",labels = c("A1", "B1", "C1","D1","E1","F1","G1"))
## Warning: Removed 18 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 18 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
delaval.SCM_quarter_doff_annotated <- annotate_figure(delaval.SCM_quarter_doff,
top = text_grob("Dry-off", color = "black",face="bold",size=20,
hjust = 0, x = 0,y=-0.75))
delaval.SCM_quarter_doff_annotated
ggsave(plot = last_plot(),"./figures/DSCC.delaval.SCM_quarter_doff.png",width = 20, height = 10, units = "cm")
# ---- C3 -----
# Neu
SCM.1_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(log.Neu) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Neu, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C3_delaval.SCM_quarter, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
SCM.2_quarter_C3 <-Pc.by.quarter.C3 %>%
filter(!is.na(log.Lym) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Lym, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C3_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
SCM.3_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(log.Mac) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Mac, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C3_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
SCM.4_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(PERCENT01_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT01_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C3_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
SCM.5_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(PERCENT02_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT02_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C3_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
SCM.6_quarter_C3 <- Pc.by.quarter.C3 %>%
filter(!is.na(PERCENT03_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT03_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C3_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
delaval.SCM_quarter_C3 <- ggarrange(SCM.1_quarter_C3 + rremove("ylab"), SCM.2_quarter_C3 + rremove("ylab"), SCM.3_quarter_C3 + rremove("ylab"),
SCM.4_quarter_C3 + rremove("ylab"), SCM.5_quarter_C3 + rremove("ylab"), SCM.6_quarter_C3 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A2", "B2", "C2","D2","E2","F2","G2"))
## Warning: Removed 13 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 3 rows containing non-finite outside the scale range
## (`stat_density()`).
delaval.SCM_quarter_C3_annotated <- annotate_figure(delaval.SCM_quarter_C3,
top = text_grob("Postpartum: 3 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
delaval.SCM_quarter_C3_annotated
ggsave(plot = last_plot(),"./figures/DSCC.delaval.SCM_quarter_C3.png",width = 20, height = 10, units = "cm")
# ---- c5 ----
# Neu
SCM.1_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(log.Neu) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Neu, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C5_delaval.SCM_quarter, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
SCM.2_quarter_C5 <-Pc.by.quarter.C5 %>%
filter(!is.na(log.Lym) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Lym, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C5_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
SCM.3_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(log.Mac) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=log.Mac, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C5_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
SCM.4_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(PERCENT01_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT01_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C5_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
SCM.5_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(PERCENT02_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT02_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C5_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
SCM.6_quarter_C5 <- Pc.by.quarter.C5 %>%
filter(!is.na(PERCENT03_N) & !is.na(delaval.SCM)) %>%
ggplot(aes(x=PERCENT03_N, group=delaval.SCM, fill=delaval.SCM)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C5_delaval.SCM_quarter, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
delaval.SCM_quarter_C5 <- ggarrange(SCM.1_quarter_C5 + rremove("ylab"), SCM.2_quarter_C5 + rremove("ylab"), SCM.3_quarter_C5 + rremove("ylab"),
SCM.4_quarter_C5 + rremove("ylab"), SCM.5_quarter_C5 + rremove("ylab"), SCM.6_quarter_C5 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A3", "B3", "C3","D3","E3","F3","G3"))
## Warning: Removed 19 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 7 rows containing non-finite outside the scale range
## (`stat_density()`).
delaval.SCM_quarter_C5_annotated <- annotate_figure(delaval.SCM_quarter_C5,
top = text_grob("Postpartum: 5 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
delaval.SCM_quarter_C5_annotated
ggsave(plot = last_plot(),"./figures/DSCC.delaval.SCM_quarter_C5.png",width = 20, height = 10, units = "cm")
DSCC.SCM_all <- ggarrange(delaval.SCM_quarter_doff_annotated + rremove("ylab"), delaval.SCM_quarter_C3_annotated + rremove("ylab"), delaval.SCM_quarter_C5_annotated + rremove("ylab"),
ncol = 1, nrow = 3, common.legend = TRUE,align = "h",widths = 4)
DSCC.SCM_all
ggsave(plot = last_plot(),"./figures/DSCC.delaval.SCM_quarter_all.png",width = 20, height = 30, units = "cm")
# ----- IMI cow level -----
# Neu
IMI.1_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(log.TOTAL.NEU.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.NEU.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fille="IMI") +
geom_vline(xintercept = optimal_neu_doff_IMI_cow, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
IMI.2_cow_doff <-Doff.by.cow.3 %>%
filter(!is.na(log.TOTAL.LYM.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.LYM.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fille="IMI") +
geom_vline(xintercept = optimal_lym_doff_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
IMI.3_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(log.TOTAL.MAC.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.MAC.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fille="IMI") +
geom_vline(xintercept = optimal_mac_doff_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
IMI.4_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(PERCENT.NEU.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.NEU.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fille="IMI") +
geom_vline(xintercept = optimal_per_neu_doff_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
IMI.5_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(PERCENT.LYM.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.LYM.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fille="IMI") +
geom_vline(xintercept = optimal_per_lym_doff_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
IMI.6_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(PERCENT.MAC.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.MAC.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fille="IMI") +
geom_vline(xintercept = optimal_per_mac_doff_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
IMI_cow_doff <- ggarrange(IMI.1_cow_doff + rremove("ylab"), IMI.2_cow_doff + rremove("ylab"), IMI.3_cow_doff + rremove("ylab"),
IMI.4_cow_doff + rremove("ylab"), IMI.5_cow_doff + rremove("ylab"), IMI.6_cow_doff + rremove("ylab"),
ncol = 3, nrow = 2, common.legend = TRUE,align = "h",labels = c("A1", "B1", "C1","D1","E1","F1","G1"))
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_density()`).
IMI_cow_doff_annotated <- annotate_figure(IMI_cow_doff,
top = text_grob("Dry-off", color = "black",face="bold",size=20,
hjust = 0, x = 0,y=-0.75))
IMI_cow_doff_annotated
ggsave(plot = last_plot(),"./figures/DSCC.IMI_cow_doff.png",width = 20, height = 10, units = "cm")
# ---- C3 -----
# Neu
IMI.1_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(log.TOTAL.NEU.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.NEU.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C3_IMI_cow, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
IMI.2_cow_C3 <-Pc.by.cow.C3 %>%
filter(!is.na(log.TOTAL.LYM.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.LYM.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C3_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
IMI.3_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(log.TOTAL.MAC.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.MAC.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C3_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
IMI.4_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(PERCENT.NEU.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.NEU.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C3_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
IMI.5_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(PERCENT.LYM.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.LYM.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C3_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
IMI.6_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(PERCENT.MAC.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.MAC.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C3_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
IMI_cow_C3 <- ggarrange(IMI.1_cow_C3 + rremove("ylab"), IMI.2_cow_C3 + rremove("ylab"), IMI.3_cow_C3 + rremove("ylab"),
IMI.4_cow_C3 + rremove("ylab"), IMI.5_cow_C3 + rremove("ylab"), IMI.6_cow_C3 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A2", "B2", "C2","D2","E2","F2","G2"))
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
## Removed 1 row containing non-finite outside the scale range (`stat_density()`).
IMI_cow_C3_annotated <- annotate_figure(IMI_cow_C3,
top = text_grob("Postpartum: 3 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
IMI_cow_C3_annotated
ggsave(plot = last_plot(),"./figures/DSCC.IMI_cow_C3.png",width = 20, height = 10, units = "cm")
# ---- c5 ----
# Neu
IMI.1_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(log.TOTAL.NEU.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.NEU.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C5_IMI_cow, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
IMI.2_cow_C5 <-Pc.by.cow.C5 %>%
filter(!is.na(log.TOTAL.LYM.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.LYM.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C5_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
IMI.3_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(log.TOTAL.MAC.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=log.TOTAL.MAC.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C5_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
IMI.4_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(PERCENT.NEU.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.NEU.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C5_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
IMI.5_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(PERCENT.LYM.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.LYM.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C5_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
IMI.6_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(PERCENT.MAC.CO.COW) & !is.na(IMI.cow)) %>%
ggplot(aes(x=PERCENT.MAC.CO.COW, group=IMI.cow, fill=IMI.cow)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fille="IMI") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C5_IMI_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
IMI_cow_C5 <- ggarrange(IMI.1_cow_C5 + rremove("ylab"), IMI.2_cow_C5 + rremove("ylab"), IMI.3_cow_C5 + rremove("ylab"),
IMI.4_cow_C5 + rremove("ylab"), IMI.5_cow_C5 + rremove("ylab"), IMI.6_cow_C5 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A3", "B3", "C3","D3","E3","F3","G3"))
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_density()`).
IMI_cow_C5_annotated <- annotate_figure(IMI_cow_C5,
top = text_grob("Postpartum: 5 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
IMI_cow_C5_annotated
ggsave(plot = last_plot(),"./figures/DSCC.IMI_cow_C5.png",width = 20, height = 10, units = "cm")
DSCC.IMI_all <- ggarrange(IMI_cow_doff_annotated + rremove("ylab"), IMI_cow_C3_annotated + rremove("ylab"), IMI_cow_C5_annotated + rremove("ylab"),
ncol = 1, nrow = 3, common.legend = TRUE,align = "h",widths = 4)
ggsave(plot = last_plot(),"./figures/DSCC.IMI_cow_all.png",width = 20, height = 30, units = "cm")
# ---- Subclinical mastitis cow-level -----
# Neu
SCM.1_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(log.TOTAL.NEU.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.NEU.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fill="High SCC") +
geom_vline(xintercept = optimal_neu_doff_SCM_cow, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
SCM.2_cow_doff <-Doff.by.cow.3 %>%
filter(!is.na(log.TOTAL.LYM.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.LYM.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fill="High SCC") +
geom_vline(xintercept = optimal_lym_doff_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
SCM.3_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(log.TOTAL.MAC.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.MAC.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fill="High SCC") +
geom_vline(xintercept = optimal_mac_doff_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
SCM.4_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(PERCENT.NEU.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.NEU.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fill="High SCC") +
geom_vline(xintercept = optimal_per_neu_doff_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
SCM.5_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(PERCENT.LYM.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.LYM.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fill="High SCC") +
geom_vline(xintercept = optimal_per_lym_doff_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
SCM.6_cow_doff <- Doff.by.cow.3 %>%
filter(!is.na(PERCENT.MAC.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.MAC.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fill="High SCC") +
geom_vline(xintercept = optimal_per_mac_doff_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
SCM_cow_doff <- ggarrange(SCM.1_cow_doff + rremove("ylab"), SCM.2_cow_doff + rremove("ylab"), SCM.3_cow_doff + rremove("ylab"),
SCM.4_cow_doff + rremove("ylab"), SCM.5_cow_doff + rremove("ylab"), SCM.6_cow_doff + rremove("ylab"),
ncol = 3, nrow = 2, common.legend = TRUE,align = "h",labels = c("A1", "B1", "C1","D1","E1","F1","G1"))
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_density()`).
SCM_cow_doff_annotated <- annotate_figure(SCM_cow_doff,
top = text_grob("Dry-off", color = "black",face="bold",size=20,
hjust = 0, x = 0,y=-0.75))
SCM_cow_doff_annotated
ggsave(plot = last_plot(),"./figures/DSCC.SCM_cow_doff.png",width = 20, height = 10, units = "cm")
# ---- C3 -----
# Neu
SCM.1_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(log.TOTAL.NEU.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.NEU.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C3_SCM_cow, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
SCM.2_cow_C3 <-Pc.by.cow.C3 %>%
filter(!is.na(log.TOTAL.LYM.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.LYM.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C3_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
SCM.3_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(log.TOTAL.MAC.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.MAC.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C3_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
SCM.4_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(PERCENT.NEU.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.NEU.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C3_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
SCM.5_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(PERCENT.LYM.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.LYM.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C3_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
SCM.6_cow_C3 <- Pc.by.cow.C3 %>%
filter(!is.na(PERCENT.MAC.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.MAC.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C3_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
SCM_cow_C3 <- ggarrange(SCM.1_cow_C3 + rremove("ylab"), SCM.2_cow_C3 + rremove("ylab"), SCM.3_cow_C3 + rremove("ylab"),
SCM.4_cow_C3 + rremove("ylab"), SCM.5_cow_C3 + rremove("ylab"), SCM.6_cow_C3 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A2", "B2", "C2","D2","E2","F2","G2"))
## Warning: Removed 5 rows containing non-finite outside the scale range
## (`stat_density()`).
## Removed 1 row containing non-finite outside the scale range (`stat_density()`).
SCM_cow_C3_annotated <- annotate_figure(SCM_cow_C3,
top = text_grob("Postpartum: 3 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
SCM_cow_C3_annotated
ggsave(plot = last_plot(),"./figures/DSCC.SCM_cow_C3.png",width = 20, height = 10, units = "cm")
# ---- c5 ----
# Neu
SCM.1_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(log.TOTAL.NEU.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.NEU.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-NEU/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_neu_C5_SCM_cow, linetype="dotted", size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Lym
SCM.2_cow_C5 <-Pc.by.cow.C5 %>%
filter(!is.na(log.TOTAL.LYM.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.LYM.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-LYM/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_lym_C5_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Mac
SCM.3_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(log.TOTAL.MAC.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=log.TOTAL.MAC.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,8) +
labs(x="log-MAC/mL",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_mac_C5_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Neu
SCM.4_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(PERCENT.NEU.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.NEU.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% NEU",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_neu_C5_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Lym
SCM.5_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(PERCENT.LYM.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.LYM.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% LYM",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_lym_C5_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# % Mac
SCM.6_cow_C5 <- Pc.by.cow.C5 %>%
filter(!is.na(PERCENT.MAC.CO.COW) & !is.na(delaval.SCM.CO.COW)) %>%
ggplot(aes(x=PERCENT.MAC.CO.COW, group=delaval.SCM.CO.COW, fill=delaval.SCM.CO.COW)) +
geom_density(adjust=1.5, alpha=.4) +
xlim(0,100) +
labs(x="% MAC",title="",fill="High SCC") +
theme(legend.position = "none") +
geom_vline(xintercept = optimal_per_mac_C5_SCM_cow, linetype="dotted",
size=1.5) +
scale_fill_manual(values = c("yellow","red"),labels=c('No', 'Yes'))
# Multipanel figure
SCM_cow_C5 <- ggarrange(SCM.1_cow_C5 + rremove("ylab"), SCM.2_cow_C5 + rremove("ylab"), SCM.3_cow_C5 + rremove("ylab"),
SCM.4_cow_C5 + rremove("ylab"), SCM.5_cow_C5 + rremove("ylab"), SCM.6_cow_C5 + rremove("ylab"),
ncol = 3, nrow = 2,align = "h",labels = c("A3", "B3", "C3","D3","E3","F3","G3"))
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_density()`).
SCM_cow_C5_annotated <- annotate_figure(SCM_cow_C5,
top = text_grob("Postpartum: 5 DIM", color = "black",face="bold",size=20,
hjust = 0, x = 0))
ggsave(plot = last_plot(),"./figures/DSCC.SCM_cow_C5.png",width = 20, height = 10, units = "cm")
DSCC.SCM_all <- ggarrange(SCM_cow_doff_annotated + rremove("ylab"), SCM_cow_C3_annotated + rremove("ylab"), SCM_cow_C5_annotated + rremove("ylab"),
ncol = 1, nrow = 3, common.legend = TRUE,align = "h",widths = 4)
DSCC.SCM_all
ggsave(plot = last_plot(),"./figures/DSCC.SCM_cow_all.png",width = 20, height = 30, units = "cm")